Generating a graph and uitable to a 2nd gui using a pushbutton

Hi guys, I would like to know how could I link a graph and an uitable to a 2nd gui. So far I have linked the graph using
second = getappdata(0, 'second');
g = findobj(second, 'type', 'axes');
axes(g)
x = data(:,2);
y = data(:,3);
plot(x,y)
My data table is something like this
z = [x y];
z = {z}; %not sure if converting it to a cell is needed
All of these are inside the pushbutton callback.

3 commentaires

What is "linking a graph"? Where does the variable "second" in the root object come from? Is it really a "table" or just a vector or matrix you want to plot? You even mention a "uitable". Rather confusing.
Gui1.fig has a pushbutton When pressed, Gui2.fig will appear and it will set data to uitable and plot a graph based on my workspace variable. What code should I put in the pushbutton callback?
Jan
Jan le 3 Déc 2017
Modifié(e) : Jan le 3 Déc 2017
What is "your workspace variable"? Each function has its own worksapce, so which worksapce do you mean? "set data to uitable" is not clear also. What does "plot a graph" mean? In the first or second figure? What is the connection to the posted code using "second = getappdata(0, 'second')"?
Of course a reader can guess, what might be meant. But guessing is inefficient and might be even more confusing, when it does not match your needs.

Connectez-vous pour commenter.

Réponses (1)

Jan
Jan le 3 Déc 2017
Modifié(e) : Jan le 3 Déc 2017
% Guessing that you use GUIDE...
function pushButtonCallback(hObject, EventData, handles)
data = handles.data; % Or wherever your data a coming from?!
NewFigureH = figure;
% Actually you do not need to specify the parent for AXES and PLOT,
% but it is safer, if the user dares to click around during the
% program runs:
AxesH = axes('Parent', NewFigureH);
plot(data(:,2), data(:,3), 'Parent', AxesH);
end
I'm not sure if this matches your needs, because I do not understand the description completely. But this is a try and it might help you to explain, what you want instead.

2 commentaires

Thank you for that answer, I went to try your code and a graph appear to another figure. Is it possible to include a table that contains the values of data(:,2) and data(:,3) beside the plotted graph?
P.S. sorry, I'm not really good at expressing myself in english.
@poop: If you are not familiar with English, the choice of your nickname might be a mistake? Nicknames can be changed in the profile.
I know that it is not easy to express a problem in a foreign language. But we do all out very best. :-)
You can create a uitable beside the plot:
AxesH = axes('Position', [0.1, 0.1, 0.4, 0.8], ...
'Parent', NewFigureH);
plot(data(:,2), data(:,3), 'Parent', AxesH);
uitable('Data', data(:, 2:3), ...
'Position', [0.55, 0.1, 0.4, 0.8], ...
'Parent', NewFigureH);

Connectez-vous pour commenter.

Catégories

En savoir plus sur 2-D and 3-D Plots dans Centre d'aide et File Exchange

Question posée :

le 2 Déc 2017

Commenté :

Jan
le 4 Déc 2017

Community Treasure Hunt

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

Start Hunting!

Translated by