Plotting into Multiple Axes in GUI

2 ビュー (過去 30 日間)
Samuel Leeney
Samuel Leeney 2020 年 10 月 16 日
回答済み: J. Alex Lee 2020 年 10 月 16 日
I am writing a signal generater where a number of different user controlled signals are varied and then fourier transformed.
I am unable to determine which axes the signals are plotted into. They default into the first axes. I have tried using 'axes(handles.SignalAxes)' but it returns an error message.
See the photo of my basic gui and an extract from the code. I need the 'fourier transform' part of the code to plot into the second of the four axes.
Thanks in advance
function Frequency_Callback(hObject, eventdata, handles)
% hObject handle to Frequency (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
f = get(hObject,'Value');
assignin('base','f',f);
setappdata(0,'f',f);
updateAll()
%there is an identical function for each of the four sliers
function updateAll
f=round(getappdata(0,'f'));
S_rate=round(getappdata(0,'S_rate'));
t=round(getappdata(0,'t'));
phi=round(getappdata(0,'phi'));
Sin_Wave(f,phi,S_rate,t)
%Fourier transform
signal = Sin_Wave(f,phi,S_rate,t);
t=linspace(0,t,S_rate);
n=length(t);
fft1 = fft(signal,n);
PSD = (fft1.*conj(fft1))./n;
freq = 1/(n.*0.0101)*(0:n);
L = 1:floor(n/2);
%axes(handles.SignalAxes) %this function results in an error message
loglog(freq(L),PSD(L)) %this should plot into the second figure in the GUI, but it does not

採用された回答

J. Alex Lee
J. Alex Lee 2020 年 10 月 16 日
Any plot command can accept as a first argument a target axes object to plot into.

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by