How to plot the sums of the columns in a matrix using a for loop?
Ältere Kommentare anzeigen
I am trying to plot the column number of matrix J versus the sum of that column using a for loop. The size of the matrix is 201 by 201. The plot should look like a sine wave, but it is not coming out correctly. This is my code so far:
for i=1:201
A=sum(J(:,i));
B=i;
end
plot(B,A)
Akzeptierte Antwort
Weitere Antworten (1)
James Tursa
am 9 Jun. 2015
Bearbeitet: James Tursa
am 9 Jun. 2015
plot(1:size(J,2),sum(J));
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!