使用polyfit对光谱进行拟合却报错。

通过读取excel文件生成一段光谱,想用polyfit函数进行一个拟合,但是运行时却报出以下错误,请问该如何解决呢?
这是代码:
clc;%清理命令行窗口
clear all;%清理工作区
%读取excel数据,同目录下
tx=xlsread('guangpu.xls');
wavelength=tx(:,1);
Intensity=tx(:,2);
plot(wavelength,Intensity,'r');
%曲线拟合
x=wavelength';
y=Intensity';
plotfit(x,y,20);
这是报出的错误:
此类型的变量不支持使用点进行索引。
出错 plotfit>unsuitable_to_plot (line 323)
elseif (net.numInputDelays > 0)
出错 plotfit (line 114)
unsuitable = unsuitable_to_plot(param,update_args{:});

 Accepted Answer

blanera
blanera on 14 May 2023

0 votes

冯京马凉的典故,可以去搜。
即使不懂,我都把出错的地方用红字标示了,这还看不出来:L
你都知道预期要用的是 polyfit ,跟我念,P,O,L,Y
结果你打成 plotfit , 成了 P,L,O,T
能对吗?

More Answers (0)

Tags

Asked:

on 14 May 2023

Answered:

on 14 May 2023

Community Treasure Hunt

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

Start Hunting!