matlab求导问题x=0:0.1:1;y=[-.447 1.978 3.11 5.25 5.02 4.66 4.01 4.58 3.45 5.35 9.22];p=polyfit(x,y,5)f=poly2str(p,'t');disp(f)d1=diff(f)Error using ==> sym.sym>expression2ref at 2408Error:Unexpected 'identifier' [line 1,col 9]Error in ==> sym.sym
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/24 08:13:16
matlab求导问题x=0:0.1:1;y=[-.447 1.978 3.11 5.25 5.02 4.66 4.01 4.58 3.45 5.35 9.22];p=polyfit(x,y,5)f=poly2str(p,'t');disp(f)d1=diff(f)Error using ==> sym.sym>expression2ref at 2408Error:Unexpected 'identifier' [line 1,col 9]Error in ==> sym.sym
matlab求导问题
x=0:0.1:1;
y=[-.447 1.978 3.11 5.25 5.02 4.66 4.01 4.58 3.45 5.35 9.22];
p=polyfit(x,y,5)
f=poly2str(p,'t');
disp(f)
d1=diff(f)
Error using ==> sym.sym>expression2ref at 2408
Error:Unexpected 'identifier' [line 1,col 9]
Error in ==> sym.sym>char2ref at 2378
s = expression2ref(x);
Error in ==> sym.sym>tomupad at 2147
S = char2ref(x);
Error in ==> sym.sym>sym.sym at 102
S.s = tomupad(x,'');
Error in ==> char.diff at 9
y = diff(sym(f),varargin{:});
matlab求导问题x=0:0.1:1;y=[-.447 1.978 3.11 5.25 5.02 4.66 4.01 4.58 3.45 5.35 9.22];p=polyfit(x,y,5)f=poly2str(p,'t');disp(f)d1=diff(f)Error using ==> sym.sym>expression2ref at 2408Error:Unexpected 'identifier' [line 1,col 9]Error in ==> sym.sym
f=poly2str(p,'t')换成f=poly2sym(p);
x=0:0.1:1;
y=[-.447 1.978 3.11 5.25 5.02 4.66 4.01 4.58 3.45 5.35 9.22];
p=polyfit(x,y,5)
f=poly2sym(p);
disp(f)
d1=diff(f)
p =
27.3878 0.1785 -20.8078 -22.5329 25.4213 -0.4429
(1927246535250589*x^5)/70368744177664 + (6429964502756005*x^4)/36028797018963968 - (2928432605711073*x^3)/140737488355328 - (6342448503305285*x^2)/281474976710656 + (1788862524623267*x)/70368744177664 - 1994708837054991/4503599627370496
d1 =
(9636232676252945*x^4)/70368744177664 + (6429964502756005*x^3)/9007199254740992 - (8785297817133219*x^2)/140737488355328 - (6342448503305285*x)/140737488355328 + 1788862524623267/70368744177664
>>
我的运行没有问题啊
问题补充:我的程序是这样的,就是对一个函数进行一次求导,如下 y1=diff消去这些0,你可以考虑控制输出结果的精度,matlab的函数是digits(用于规定