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 件のコメント

Jan
Jan 2017 年 12 月 2 日
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
poop 2017 年 12 月 3 日
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 日

0 投票

% 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 件のコメント

poop
poop 2017 年 12 月 4 日
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.
Jan
Jan 2017 年 12 月 4 日
@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