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 CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by