フィルターのクリア

GUI to plot sine and cosine given amplitude and frequency

7 ビュー (過去 30 日間)
Amir
Amir 2012 年 8 月 21 日
コメント済み: Bordin Vang 2020 年 10 月 27 日
My intention is to generate a GUI in Matlab in order to plot sine and cosine (chosen by a popup menu from user) while taking the values for amplitude and frequency from edittext inputs.
My GUI code shown below, can easily plot sine (or even cosine). However, it seems as if I have a problem making the popupmenu working correctly.
I realize this sounds very basic for actual GUI users, but it is essential for me to learn by making these simple cases work. any help is greatly appreciated.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Here is a link to my Matlab Script which plots but its popupmenu has problem:
https://www.dropbox.com/sh/gwjbllbzfdvyxe1/Th2Rn8V8fE
  1 件のコメント
Bordin Vang
Bordin Vang 2020 年 10 月 27 日
can you post your files again? the dropbox link isnt working anymore.

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

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 8 月 21 日
you have just to program you puchbutton callback
function pushbutton1_Callback(hObject, eventdata, handles)
% when the button plot is pushed
f = str2num(get(handles.edit1,'String')); %geting f
A = str2num(get(handles.edit2,'String')); % geting A
t = 1:100
sine = A* sin(0.02*pi*f*t);
cosine = A * cos(0.02*pi*f*t);
val =double(get(handles.popupmenu1,'Value')); %geting popupmenu value(1 or 2)
if val==1
plot(sine);
else
plot(cosine)
end
  1 件のコメント
Amir
Amir 2012 年 8 月 22 日
編集済み: Amir 2012 年 8 月 22 日
Thanks Azzi,
It worked!
One final question though:
I was wondering whether you have any suggestions as to how I could give the user an option of choosing a color for the plots by choosing from a Listbox? or perhaps even using the Slider for the color spectrum? I will try implementing my script draft and will update it here later on. But for now, can you think of a better way to do that?
Thanks, - Amir

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSubplots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by