Generating a graph and uitable to a 2nd gui using a pushbutton
Mostrar comentarios más antiguos
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 comentarios
Jan
el 2 de Dic. de 2017
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.
poop
el 3 de Dic. de 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.
Respuestas (1)
% 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 comentarios
poop
el 4 de Dic. de 2017
Jan
el 4 de Dic. de 2017
@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);
Categorías
Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!