I made a GUI in GUIDE, and ran into what seems like a simple issue, but I can't figure out what I'm overlooking.
I have an "execute" push button, which when pressed, checks the state of a "frequency plot" toggle button. If "frequency plot" button is active, a function to plot some data runs.
Inside the plotting function, I have:
if get(handles.toggle1,'Value')==1
fdata{1,1}=...
fdata{1,2}=...
end
I do this because the data can be used for different plots, and might not necessarily be used in this case. This is controlled by a toggle button. If the button is active, I add the data to a cell which is plotted.
I get the error: ??? Undefined variable "handles" or class "handles.toggle1".
I can't figure out why. I use this same line with set elsewhere in the program (not this function) and it access it fine.

 採用された回答

Walter Roberson
Walter Roberson 2011 年 11 月 2 日

0 投票

Is handles being passed in to the plotting function?
Is the toggle button being created dynamically, or was it created statically and is part of your stored .fig file ?

3 件のコメント

Jared
Jared 2011 年 11 月 2 日
All toggle buttons are static and were created in GUIDE.
I'll try to explain it better. I have 2 toggle buttons "Frequency" and "File 1", and 1 push button "Execute".
On pressing of "Execute", I check the state of "Frequency" toggle by only using:
if get(handles.togglefplot,'Value')==1;
fplot
end
When "Frequency" is active, and I press "Execute", it jumps to my fplot function. Inside fplot, I try to check if "File 1" is active with the same code as above. However, I get that error. As far as I can see, I did nothing different that when I checked the state of "Frequency".
Fangjun Jiang
Fangjun Jiang 2011 年 11 月 2 日
Is fplot.m a M-function or a M-script. If it is a M-function, you have to pass handles to your function fplot(). Right now, fplot() doesn't seem to have any input argument.
Walter Roberson
Walter Roberson 2011 年 11 月 2 日
You are not passing handles to fplot. Redefine you fplot to accept handles as a parameter:
function fplot(handles)
instead of your current
function fplot
and invoke it in the Execute callback with
fplot(handles)

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Develop Apps Using App Designer についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by