Creating a function to plot multiple column of a variable in workspace
조회 수: 4 (최근 30일)
이전 댓글 표시
I have a array which is 729 by 9
.
.

.
.
Currently I am plotting the different columns in the same plot using the follow command:
.
plot(wavelengtha(:,1), Raman);
hold on;
plot(wavelengtha(:,2), Raman);
hold on;
plot(wavelengtha(:,3), Raman);
hold on;
plot(wavelengtha(:,4), Raman);
hold on;
.
.
.
.
plot(wavelengtha(:,9), Raman);
.
. This is still manageable as its only 9 columns. however in later stage, I will have arrays stretching up to 100+ columns. I was thinking of putting the above code in function. Where I will then key in the name of the variable to plot all the columns as y-axis.
. Can Someone help me with this?
댓글 수: 0
채택된 답변
Roger Stafford
2014년 10월 26일
Just use a for-loop for this purpose:
for k = 1:n
plot(wavelengtha(:,k), Raman);
hold on
end
What could be simpler?
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!