Send data to a different fig. window

11 views (last 30 days)
Samuel
Samuel on 15 Feb 2011
Hello everyone,
I made two fig. windows by Matlab GUIDE. A fig. window receives all datas and calculate them then, I want to send the result of calculation to B fig. window in order to plot the result.
I have tried many ways but all failed. Please help me to solve this problem. I want to either send the data to B fig.window or read input datas in A fig.window at B window when I open it.
Thanks.

Accepted Answer

Matt Fig
Matt Fig on 15 Feb 2011
Set the axes in B figure with a tag to look for from the GUI callback where the data is calculated.
% Inside callback where data is made in A GUI.
dat_x = %%%Some calculation
dat_y = %%Some calculation
AX = findobj('type','axes','tag','myaxes'); % AX in in B GUI.
plot(AX,dat_x,dat_y)
.
.
.
.
. . . . . .
EDIT
If you are getting a "Vectors must be the same lengths." error, then either you have not gotten AX correctly (perhaps you found more than one axes because you didn't tag one uniquely like I showed), or w and H are different lengths. So check:
isequal(1,numel(AX))
isequal(size(w),size(H))
If AX is empty, it could be that the axes handle is hidden especially if this was a GUIDE GUI. In that case, use:
findall(0,'type','axes','tag','myaxes')% Use the tag you gave.
.
.
.
.
. . . . . .
EDIT #2
If the FINDALL function didn't find the axes in B GUI, then I must ask you if you remembered to put a tag in the 'tag' property of the axes when you made the figure. It looks like you just copied and pasted what I wrote without using your own tag. If you don't tag the axes, FINDALL cannot find it the way you called it. In GUIDE open up the axes property inspector and fill in a value for the 'tag' property. Then use this same value in the call to FINDALL. Let me know if it works then.
Also, just to be sure, both GUIs are open at the same time, right? You are not trying to access an axes in a figure (fig B) that isn't opened, right?
  1 Comment
Samuel
Samuel on 16 Feb 2011
Hi
I really really appreciate your help.
It works!!!! I tried to access without open it. Can I ask one more question??
How to clear the previous axes and replot new data??? If I try to replot on same axes it gives me same error.
Thanks again.

Sign in to comment.

More Answers (2)

Samuel
Samuel on 15 Feb 2011
Thank you for your help. I could understand its concept. But I still have an error below. without AX, it works fine(plot on my A.fig).
??? Error using ==> semilogx Vectors must be the same lengths.
Error in ==> Bandpass>LPbutton1_Callback at 115 semilogx(AX,w,abs(H));
Error in ==> gui_mainfcn at 96 feval(varargin{:});
Error in ==> Bandpass at 42 gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)Bandpass('LPbutton1_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback

Samuel
Samuel on 16 Feb 2011
Thanks a lot again. I tested the code then got the ans below
AX = findobj('type','axes','tag','myaxes1') % AX in in B GUI.
isequal(1,numel(AX))
isequal(size(w),size(H)) AX =
Empty matrix: 0-by-1
ans =
0
ans =
1
H and w have same length. but AX is empty. So, I used new code you gave above, however, I got same error.
here is the code.
AX = findall(0,'type','axes','tag','myaxes1');
semilogx(AX,w,abs(H));
AX is still empty. like this -> AX = Empty matrix: 0-by-1
I looked up GUI manuel. It seems to be right.
But I couldn't make it...

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!