how to plot from a 60dimension array in one figure.

조회 수: 2 (최근 30일)
Eddy van der Goot
Eddy van der Goot 2018년 7월 16일
댓글: Adam Danz 2018년 7월 17일
Hi, I have a Array 1989 x 4 x 60 each dimension containing spectra measurments. now I want to plot all in on figure with: figure1=figure hold on x = AmplitudeArray(:,1,1) for i=1:1:60 y = AmplitudeArray(:,4,i) plot (x,y) end
unfortunately this results in only 5 spectra to be plotted instead of the 60 I need.
  댓글 수: 3
Eddy van der Goot
Eddy van der Goot 2018년 7월 16일
I can see only 5 but it would be strange to have the other 55 overlap in such a way that they would disappear. the measurements are spectra from eggs a natural product that produces different responses with each different egg.
Adam Danz
Adam Danz 2018년 7월 16일
편집: Adam Danz 2018년 7월 16일
Some diagnostics to try
  • Scroll through values of the array to make sure the values make sense and are in the expected ranges. Are they all NaN, inf, -inf, etc?
  • Step through your for-loop in debug mode and see each set of data updated on the plot. If you don't see an update, look at those x,y values to determine why.
  • Are you limiting your axis ranges (xlim, ylim) such that only some of your data are visible?
  • Is your for-loop actually executing 60 times?
  • Is the size of your array the size that you expect?
  • Are some of your data much greater in value than other data such that the axes are being collapsed and smaller data becomes invisible?

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

채택된 답변

Adam Danz
Adam Danz 2018년 7월 16일
편집: Adam Danz 2018년 7월 16일
First, please format your code in order to minimize the work that needs to be done for people to troubleshoot your code.
I just simulated your data with random numbers using the size you described. Note that this is a 3 dimensional array (not 60).
AmplitudeArray = rand(1989,4,60);
When I executed your code, the for-loop plotted all 60 iterations. So check these:
  • size(AmplitudeArray)
  • the value of i at the end of the loop
Lastly, you can skip the for-loop and do all the plotting in 1 line of code.
plot(repmat(AmplitudeArray(:,1,1),1,60), squeeze(AmplitudeArray(:,4,[1:60])))
  댓글 수: 2
Eddy van der Goot
Eddy van der Goot 2018년 7월 17일
this works, thanks for the help
Adam Danz
Adam Danz 2018년 7월 17일
Great, my pleasure.

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by