필터 지우기
필터 지우기

App Designer - Reading Value from Edit Field at Startup

조회 수: 3 (최근 30일)
PADMAKAR
PADMAKAR 2022년 3월 4일
편집: Cris LaPierre 2022년 3월 5일
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

채택된 답변

Cris LaPierre
Cris LaPierre 2022년 3월 4일
편집: Cris LaPierre 2022년 3월 5일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by