Variable names whch include numerics

조회 수: 2 (최근 30일)
Bob Matthews
Bob Matthews 2020년 5월 7일
답변: Mehmed Saad 2020년 5월 7일
I have imported a .csv file choosing column vectors
I have ended up with doubles named VarName1, VarName2, VarName3 etc.
I wsh to populate a cell array with these doubles
Can I use a for next loop with i=1:x, and if so, how does one reference say VarName3 when i = 3
Cheers
Bob M

채택된 답변

Mehmed Saad
Mehmed Saad 2020년 5월 7일
I know the most inefficient way to do that. (eval)
varNames1 = rand(20,1);
varNames2 = rand(20,1);
varNames3 = rand(20,1);
for i=1:3
C{i} = eval(sprintf('varNames%i',i));
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by