HOW TO CALCULATE LINE BY LINE

1 回表示 (過去 30 日間)
heir ancestors
heir ancestors 2017 年 1 月 26 日
回答済み: Jan 2017 年 1 月 26 日
Hello Every one ; I have a matrix A of a 6*7 elements
A11 A21 A31 A41 ...
A12 A22 A32 A42 ...
A13 A23 A33 A43 ...
. . . . ...
if I want to make a for loop but I want to calculate line by line : I mean : I want to calculate : A11, A12, A13...after go to the second column calculate : A21,A22,A23, after go to third column calculate : A31,A32,A33 ....
If I put the loop
[s z]=size(A)
for i=1:s-1
for j=1:z
for y=2:s
B(i,j)=A(i,j)+cosd (A(y,j))
end
end
end
How can I calculate line by line ? Calculates first line of elements, then second line of elements then third ...as explained before ?
Thank you in advance

回答 (1 件)

Jan
Jan 2017 年 1 月 26 日
Perhaps this helps already:
A = rand(3,4);
for iLine = 1:3
disp(A(iLine, :))
end

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by