Keep getting error in polyfit
显示 更早的评论
>> x = table2array(Test1_x);
>> y = table2array(Test1_y);
I keep getting this error in polyfit. Here is the code and output from Matlab during a simple test. x and y should be arrays of real numbers.
-----------------------------------------
>> poly_fit_coef = polyfit(x, y, 1);
Error using ones
CLASSNAME input must be a valid numeric class name.
Error in polyfit (line 59)
V(:,n+1) = ones(length(x),1,class(x));
--------------------------------------
What is wrong here?
Thanks in advance for any help!
Jennifer
采纳的回答
更多回答(1 个)
Image Analyst
2015-10-26
编辑:Image Analyst
2015-10-26
What does this say?
whos x
class(x)
whos y
class(y)
which -all polyfit
4 个评论
JFz
2015-10-26
Image Analyst
2015-10-26
Like I thought, it wasn't a vector of numbers, but of strings.
Star Strider
2015-10-26
Well, all it said was ‘cell’. That could be anything.
Image Analyst
2015-10-26
True. Since it came from table2array(), and we knew it wasn't a double, single, or an integer because it said "CLASSNAME input must be a valid numeric class name.", the most likely option that it would be is a cell array. Any cell array would generate this error - a cell array of strings, doubles, integers, etc.
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!