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
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
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개)
% 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
2017년 12월 4일
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에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!