필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

regenerate Array name form Plot (Important Question)

조회 수: 1 (최근 30일)
Max Müller
Max Müller 2014년 8월 20일
마감: MATLAB Answer Bot 2021년 8월 20일
Hey Guys, This is a very important question, which will decide the way I script my program.However it is quite simple.
If i plot (for exmaple x = 1:10 / Rainbow = 1:2:20), is it possible to get back the name of the plotted Arrays ( x and Rainbow ) ?
The reason behind my Question is: I am creating a GUI which allows the use to change Points in the Plot. Now i need a way to 100% identify the Array which was plotted.( There several Plotlines in one axes)

답변 (3개)

Star Strider
Star Strider 2014년 8월 20일
Not to my knowledge. They’re known to the axes object as 'XData' and 'YData'. If you label the axes with the array names you can of course get them as 'XLabel' and 'YLabel'. There is also a 'UserData' matrix (that I’ve never used) that you can store in and retrieve information from. The 'UserData' property may be your best option.

Joseph Cheng
Joseph Cheng 2014년 8월 20일
I would say when you're defining each plot you also set the X and Y data source parameters located in the axes properties. See my example:
x = 1:10;rainbow = 1:2:20;
fig = figure;
hold on
for ind =1:4
ax(ind) = plot(ind*x,ind*rainbow);
set(ax(ind),'XDataSource',['x*' num2str(ind)])
set(ax(ind),'YDataSource',['raibow*' num2str(ind)])
end
for ind =1:4
disp(['plot ' num2str(ind) ': was ' get(ax(ind),'XDataSource') ' and ' get(ax(ind),'YDataSource')])
end
  댓글 수: 1
Joseph Cheng
Joseph Cheng 2014년 8월 20일
Which now thinking about it more could be easy to implement as depending on how you are defining the multiple plots on the axis. If there is a X list box and another for Y plus an Add to plot button then in the add to plot button would get the name from the xname=get(handles.listboxX,'String) then from that get the index.

Max Müller
Max Müller 2014년 8월 21일
Thanks for your suggestions. I guess i will save the PlotData wiht there names and prosperitys in my GUI. That will cause some calculation time however it will be the saver version. (Due to the fact that i am not very good in matlab :D )

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by