Plotting into Multiple Axes in GUI

조회 수: 1 (최근 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 CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by