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

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 2017년 12월 3일
편집: Jan 2017년 12월 3일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2017년 12월 3일
편집: Jan 2017년 12월 3일
% 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

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);

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터 및 File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

질문:

2017년 12월 2일

댓글:

Jan
2017년 12월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by