I am trying to make a CDFplot for a box dimensions but I am getting an error because I have 1+ in my depth column. How can I search for the + and replace it with to 1.1.
At the moment my script is :
load ('MyFileName.mat')% this is an example tilte
figure; % depth
cdfplot(MyFileName.boxDepth);
title(Box Depth)
xlabel('Depth (m)')
ylabel(cdf)
The error I am getting is:
Undefined function 'isnan' for input arguments of type ' categorical'.
Error in cdfcalc (line 39)
x=x(~isnan(x));
Error in cdfplot (line 41)
[yy,xx,~,~,eid] = cdfcalc(x);
Thank you

답변 (1개)

Cris LaPierre
Cris LaPierre 2020년 11월 13일

0 개 추천

You've shared the wrong code. The error is in your cdfplot function.
There appears to be a datatype error as well. Perhaps because one of the values is "1+", your data is categorical. It makes it easy to rename the wrong category - use renamecats. I imagine for a cdf plot you need the data to be numeric not categorical. You could use str2double to convert your variable.
You could also just keep your data double, which would likely assign this element a value of "NaN". You could then use fillmissing.

댓글 수: 3

Sitara Smith
Sitara Smith 2020년 11월 16일
Thank you very much Cris LaPierre for answering my question. I am new to Matlab,will it be possible if you could show me an example on how I can search for the + and replace it with to 1.1 and plot a cdf.
Thanks
Cris LaPierre
Cris LaPierre 2020년 11월 16일
You'll find examples of how to use the functions I mentioned in each of the linked documentation pages. Look for "Examples" in the left hand navigation menu.
Sitara Smith
Sitara Smith 2020년 11월 16일
Thank you Cris. I will have a look.

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

제품

릴리스

R2018b

질문:

2020년 11월 13일

댓글:

2020년 11월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by