matlab运行程序时出现To RESHAPE the number of elements must not change.麻烦高手帮忙看看该怎么改?clearclcsyms a1 a2 a3 a4 a5 th t hth=360h=360/7w=2*pi/ths=h*t/th-(a1/(1*w)^2)*sin(1*w*t)-(a2/(2*w)^2)*sin(2*w*t)-(a3/(3*w)^2)*sin(3*w*t)
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/22 14:52:24
matlab运行程序时出现To RESHAPE the number of elements must not change.麻烦高手帮忙看看该怎么改?clearclcsyms a1 a2 a3 a4 a5 th t hth=360h=360/7w=2*pi/ths=h*t/th-(a1/(1*w)^2)*sin(1*w*t)-(a2/(2*w)^2)*sin(2*w*t)-(a3/(3*w)^2)*sin(3*w*t)
matlab运行程序时出现To RESHAPE the number of elements must not change.麻烦高手帮忙看看该怎么改?
clear
clc
syms a1 a2 a3 a4 a5 th t h
th=360
h=360/7
w=2*pi/th
s=h*t/th-(a1/(1*w)^2)*sin(1*w*t)-(a2/(2*w)^2)*sin(2*w*t)-(a3/(3*w)^2)*sin(3*w*t)-(a4/(4*w)^2)*sin(4*w*t)-(a5/(5*w)^2)*sin(5*w*t);
f=int(s^2,t,0,th*82/360)+int((s-h)^2,t,268*th/360,th);
f1=diff(f,a1);
f2=diff(f,a2);
f3=diff(f,a3);
f4=diff(f,a4);
f5=diff(f,a5);
[a1,a2,a3,a4,a5]=solve(f1,f2,f3,f4,f5,'a1,a2,a3,a4,a5')
Error using ==> reshapeTo RESHAPE the number of elements must not change.
Error in ==> sym.maple at 94 result = reshape(result,size(varargin{3}));
Error in ==> sym.sin at 7Y = maple('map','sin',X);
Error in ==>
s=h*t/th-(a1/(1*w)^2)*sin(1*w*t)-(a2/(2*w)^2)*sin(2*w*t)-(a3/(3*w)^2)*sin(3*w*t)-(a4/(4*w)^2)*sin(4*w*t)-(a5/(5*w)^2)*sin(5*w*t);
Error in ==>
f=int(s^2,t,0,th*82/360)+int((s-h)^2,t,268*th/360,th);
matlab运行程序时出现To RESHAPE the number of elements must not change.麻烦高手帮忙看看该怎么改?clearclcsyms a1 a2 a3 a4 a5 th t hth=360h=360/7w=2*pi/ths=h*t/th-(a1/(1*w)^2)*sin(1*w*t)-(a2/(2*w)^2)*sin(2*w*t)-(a3/(3*w)^2)*sin(3*w*t)
楼上的回答纯属想当然.表达式中所有的符号都是标量,乘号加点干什么?
我觉得是MATLAB版本问题.不知道楼主用的是什么版本——R2008a之前的版本,或是R2008b之后的版本+Maple工具箱?
我用楼主的代码在6.5上求解没任何问题,输出结果见后;但是在R2008b求解卡在solve那句,很长时间算不出来,后来被我中断了.下面这句用的时间也比较长,但是能算出来,也并没有见到楼主贴出的错误:
f=int(s^2,t,0,th*82/360)+int((s-h)^2,t,268*th/360,th);
th =
360
h =
51.4286
w =
0.0175
a1 =
.43990456374271334532192607021991e-2
a2 =
-.59745994549994813570911518799801e-2
a3 =
.45093107661604975964880408427690e-2
a4 =
-.20472736897032618866319876497779e-2
a5 =
.4576363290121001608986881601298e-3