Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

regenerate Array name form Plot (Important Question)

3 visualizzazioni (ultimi 30 giorni)
Max Müller
Max Müller il 20 Ago 2014
Chiuso: MATLAB Answer Bot il 20 Ago 2021
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)

Risposte (3)

Star Strider
Star Strider il 20 Ago 2014
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 il 20 Ago 2014
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 Commento
Joseph Cheng
Joseph Cheng il 20 Ago 2014
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 il 21 Ago 2014
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