Assigning a variable according to file name..
조회 수: 16 (최근 30일)
이전 댓글 표시
I want the variable to be changed according to the file name.. Like;
Simulation File 1 Track 2
Simulation File 1 Track 4
Simulation File 1 Track 6
.
.
.
I want those track values assigned in a formula and get the value as the loop continues taking the track value like 2-4-6. Thank you all
답변 (2개)
KSSV
2020년 10월 12일
You need not to change the variable as based on filename..you can initialize an array/ matrix and save the variables into this.
Option 1: If size is always same
n = 10 ; % number of files
iwant = zeros(3,3,n) ; %
for i = 1:n
iwant(:,:,i) = rand(3) ; % save data here
end
Otion 2: If size varies
n = 10 ;
iwant = cell(n,1) ;
for i = 1:n
m = randperm(100,1) ;
iwant{i} = rand(m) ;
end
댓글 수: 0
Sudhakar Shinde
2020년 10월 12일
Example:
Track = 2;
File = 2;
Filename = {};
for j=1:(File)
for i = 1:(Track)
Filename{end+1} = ['SimulationFile' num2str(j) , ' Track' num2str(i)];
end
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Whos에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!