Send data to a different fig. window

11 ビュー (過去 30 日間)
Samuel
Samuel 2011 年 2 月 15 日
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.

採用された回答

Matt Fig
Matt Fig 2011 年 2 月 15 日
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 件のコメント
Samuel
Samuel 2011 年 2 月 16 日
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.

サインインしてコメントする。

その他の回答 (2 件)

Samuel
Samuel 2011 年 2 月 15 日
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 2011 年 2 月 16 日
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...
  1 件のコメント
Matt Fig
Matt Fig 2011 年 2 月 16 日
See my response above in EDIT#2.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by