I have to plot all the signals in one figure

3 ビュー (過去 30 日間)
Harshini Gangapuram
Harshini Gangapuram 2018 年 9 月 29 日
回答済み: JohnGalt 2018 年 10 月 1 日
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
load sampleEEGdata
time = -1:1/EEG.srate:1;
step=(2+30)/5;
for f=2:step:30
% create sine wave
sine_wave = cos(2*pi*f.*time);
% make a Gaussian
s=4/(2*pi*f);
gaussian_win = exp(-time.^2./(2*s^2));
figure
plot(time,sine_wave.*gaussian_win)
hold on
end
guidata(hObject, handles);
  4 件のコメント
Abdurrehman
Abdurrehman 2018 年 9 月 29 日
Your code is not readablereadable please use"code" in MATLAB Answers text editor
Abdurrehman
Abdurrehman 2018 年 9 月 29 日
For plotting instead of writing figure define figure no and then plot e.g. figure(2)

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

回答 (1 件)

JohnGalt
JohnGalt 2018 年 10 月 1 日
if you want a new window for every for-loop try:
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
load sampleEEGdata
time = -1:1/EEG.srate:1;
step=(2+30)/5;
figure % create the figure window
hold on
for f=2:step:30
% create sine wave
sine_wave = cos(2*pi*f.*time);
% make a Gaussian
s=4/(2*pi*f);
gaussian_win = exp(-time.^2./(2*s^2));
plot(time,sine_wave.*gaussian_win)
end
guidata(hObject, handles);

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by