'Value' must be double scalar within the range of 'Limits'

조회 수: 10(최근 30일)
Hi. I am creating a gui on appdesigner. I am reading numeric data from a csv file and storing this data in an array. I want to calculate the standard deviation of the values store in the array and display it on the numeric edit field. The error I get is 'Value' must be a double scalar within the range of 'Limits'. But my Limit of the editfield is -Inf,Inf. The csv file is attached and the code is provided below. Please assist.
I tried editing the code to :
But the error still pops up.
  댓글 수: 4
Lola 2022년 6월 16일
Hi. I have attached the csv file that has the results in it. It is column 2. I'm reading the values after 9 rows

댓글을 달려면 로그인하십시오.

채택된 답변

Adam Danz
Adam Danz 2022년 6월 16일
편집: Adam Danz 2022년 6월 16일
Your data contains a NaN value.
n = sum(isnan(col_vec));
fprintf('There are %d NaN values in col_vec\n', n)
There are 1 NaN values in col_vec
ans = NaN
Where is the NaN value?
nanLoc = find(isnan(col_vec));
fprintf('NaN in row %d', nanLoc)
NaN in row 789
When there is at least 1 NaN in a vector, std will return NaN.
  1. Figure out why there are NaNs and replace them (manually, smoothing, interpolation, etc)
  2. Ignore the NaNs: S = std(___,nanflag)
sd = std(col_vec,'omitnan')
sd = 37.5436
  댓글 수: 2

댓글을 달려면 로그인하십시오.

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by