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