App Designer - Reading Value from Edit Field at Startup
2 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
採用された回答
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/100
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!