No data plotted in graph

조회 수: 4 (최근 30일)
Ellen Walker
Ellen Walker 2018년 9월 18일
댓글: Ellen Walker 2018년 9월 19일
I am trying to plot two curves on the same graph for multiple animals and multiple sessions for each animal that will generate a new plot for each neuron.
Also, I would like one curve to be green and the other red, as stated below, but, in the legend, both are appearing green.
I have tried the following code and get a graph with the proper axes but no data plotted:
sm=smooth(M,500,'lowess');
sm2=smooth(N,500,'lowess');
nunit=nunit+1;
plot(sm,nunit,'g',sm2,nunit,'r');
legend('MV in water','2H in saccharin');
title({animal;session})
Not sure what I am doing wrong; thank you for your help!!
  댓글 수: 2
dpb
dpb 2018년 9월 19일
...
nunit=nunit+1;
plot(sm,nunit,'g',sm2,nunit,'r');
...
nunit is just a single point and you don't have a marker and since there's not more than one point between which plot() can draw a line, there's nothing going to show up.
Also, if you're going to plot in a loop, then you needs must use
hold on
in order for each subsequent point to not erase those who've gone before.
In general you should generate all the data to plot first, then call plot() with and X,Y array to do the plotting.
Also while you've not shown the loop, as shown you would be rewriting the legend and title every pass; even if you continue to plot point-by-point, move those out and wait until the loop is complete.
One thing you can do in your existing code to see what's happening as it currently is written is use
plot(sm,nunit,'gx',sm2,nunit,'ro');
pause 0.1
Ellen Walker
Ellen Walker 2018년 9월 19일
Thank you for your help!!

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Animation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by