Azzera filtri
Azzera filtri

App Designer - Reading Value from Edit Field at Startup

3 visualizzazioni (ultimi 30 giorni)
I am reading a value from Edit field and performing simple computation. The computation is incorrect. Where is the error coming from? See pictures and code below.
function startupFcn(app)
%--------------------------------------------------------------------------
% Create an Ricker wavelet using Ricker function from CREWES function list
%--------------------------------------------------------------------------
% wl=wavelet length in seconds
app.sr=app.SampleIntmsEditField.Value; % The value of 1 ms is read correctly. See picture 1.
app.sr=app.sr/1000;% The computed value is 0.049 instead of 0.001 What is causing this error?
tw=app.NoOfSamplesEditField.Value;
Fs=1/sr;
wl=sr/Fs*length(tw)- (sr/Fs);%subtract one sample in sec.since the ricker fn adds one sample to time vector
[wr,tw2] = ricker2(sr/Fs,fpeak,wl);%ricker2 function also returns time vector tw2 with tw2=wl+1 sample
tw2=tw2*Fs;
end

Risposta accettata

Cris LaPierre
Cris LaPierre il 4 Mar 2022
Modificato: Cris LaPierre il 5 Mar 2022
Pay attention to data types. Your value of 1 is a char, not a double. You must be using a text edit field instead of a numeric edit field. Try replacing it with the Edit Field (Numeric) component and then rerun your calculation.
sr = '1'
sr = '1'
sr/100
ans = 0.4900

Più risposte (0)

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by