Filter löschen
Filter löschen

App Designer - Reading Value from Edit Field at Startup

3 Ansichten (letzte 30 Tage)
PADMAKAR
PADMAKAR am 4 Mär. 2022
Bearbeitet: Cris LaPierre am 5 Mär. 2022
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

Akzeptierte Antwort

Cris LaPierre
Cris LaPierre am 4 Mär. 2022
Bearbeitet: Cris LaPierre am 5 Mär. 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

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by