필터 지우기
필터 지우기

Update plot using set() with xData and yData

조회 수: 151 (최근 30일)
m j
m j 2020년 7월 28일
댓글: Cris LaPierre 2020년 7월 29일
Hello,
Im trying to set a plot handle by updating its xData and ydata.I have a 2048X8 array of doubles called normWanted = 2048X8 of double type.
Ive tried:
set(hPlot3, 'Xdata',1:2048,'Ydata',normWanted);
I get the error"Value must be a vector of numeric type"
Now if I try: set(hPlot3, 'Xdata',1:2048,'Ydata',normWanted(:,1)); <- this works but only plots 1,would like to plot all 8 arrays
Any ideas on how to plot this using set or a better way,I have a figure with multiple subplots so?
  댓글 수: 2
jonas
jonas 2020년 7월 28일
What exactly is hPlot3? Is it an array of handles? Are you trying to update 8 line handles?
m j
m j 2020년 7월 29일
편집: m j 2020년 7월 29일
hAxes3 = subplot(2,2,1);
hPlot3 = plot(hAxes3, nan,nan); This is what it is.

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

채택된 답변

Cris LaPierre
Cris LaPierre 2020년 7월 29일
When you plot multiple lines in a single plol, your handle is an array of line objects, one for each line. If you want to use the XData and YData properties, you must first create a line object for each data set you want to display. Then you would have to update the XData and YData properties of each line one at a time.
hPlot3 = plot(hAxes3, nan,nan, nan,nan, nan,nan, nan,nan, nan,nan, nan,nan, nan,nan, nan,nan);
set(hPlot3(1),'XData',1:2048,'YData',normWanted(:,1))
set(hPlot3(2),'XData',1:2048,'YData',normWanted(:,2))
...
set(hPlot3(8),'XData',1:2048,'YData',normWanted(:,8))
  댓글 수: 3
m j
m j 2020년 7월 29일
편집: m j 2020년 7월 29일
You assumed wrong lol! I didnt know that it wasnt necessary to specify the axes,and that subplot and plot worked this way.....dafaq lol!
This works, And it works when updating plot and changing background of plot using: set(gca,'color','black');......Thank you kind sir.
Unless you can think of a better way? My goal so far, is to just plot signals in a axes after I have padded them.Pretty simple.
Cris LaPierre
Cris LaPierre 2020년 7월 29일
If you haven't already done so, I suggest going through Chapter 9 of MATLAB Onramp. It doesn't get this in depth, but it does give a good intro to plotting in MATLAB, and only takes about 15 minutes.

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by