looping with for through variables with multiple columns

Hi all!
I have 33 variables with multiple columns.. Does anyone knows how would be the statement in for loop?
sza = ["20_0","50_0","80_0"];
tau = ["0_0","0_5","1_0","1_5","2_0","3_0","4_0","5_0","10_0","15_0","20_0"];
for i=1:length(sza)
for j=1:length(tau)
statement
end
end
statement for just one double array: X20_0sza0_0tau(:,8) = (X20_0sza0_0tau(:,5) + X20_0sza0_0tau(:,6)).*4*pi;

댓글 수: 1

X20_0sza0_0tau(:,8) = ...
It looks like you are putting meta-data into variable names. Meta-data is data, and should NOT be in variable names.
Accessing (meta-)data in variable names is one way that beginners force themselves into writing slow, complex, obfuscated, buggy code that is hard to debug. Read this to know why:
Most likely you should be using one array (e.g. numeric, structure, table, etc.) and accessing the data in that array.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

2020년 1월 18일

댓글:

2020년 1월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by