Plotting into Multiple Axes in GUI

2 visualizzazioni (ultimi 30 giorni)
Samuel Leeney
Samuel Leeney il 16 Ott 2020
Risposto: J. Alex Lee il 16 Ott 2020
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

Risposta accettata

J. Alex Lee
J. Alex Lee il 16 Ott 2020
Any plot command can accept as a first argument a target axes object to plot into.

Più risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by