matlab solve 求解方程组遇到Error using ==> subsasgn代码如下1#是没加循环时可以运行,2#是加循环是出现报错报错内容:Error using ==> subsasgnIn an assignment A(:) = B,the number of elements in A and Bmust be the same.Err

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/06 17:15:16
matlab solve 求解方程组遇到Error using ==> subsasgn代码如下1#是没加循环时可以运行,2#是加循环是出现报错报错内容:Error using ==> subsasgnIn an assignment A(:) = B,the number of elements in A and Bmust be the same.Err

matlab solve 求解方程组遇到Error using ==> subsasgn代码如下1#是没加循环时可以运行,2#是加循环是出现报错报错内容:Error using ==> subsasgnIn an assignment A(:) = B,the number of elements in A and Bmust be the same.Err
matlab solve 求解方程组遇到Error using ==> subsasgn
代码如下1#是没加循环时可以运行,2#是加循环是出现报错
报错内容:
Error using ==> subsasgn
In an assignment A(:) = B,the number of elements in A and B
must be the same.
Error in ==> sym.subsasgn at 33
y = builtin('subsasgn',sx,a,b);
一直没找到原因
%1#
clc
clear
syms Z0 K ;
E1=30.336*1000;%Mpa
E2=69*1000; %AL(Mpa)
E3=E1;
D1=1350/1000000;
D3=-D1/3;
a=0.32; %mm
b=0.4;
Z1=Z0+a;
Z2=Z1+b;
Z3=Z2+a;
M1=(1/3)*b*E1*K*(Z3^3-Z2^3)+(1/2)*b*E1*D1*(Z2^2-Z3^2);
M2=(1/3)*b*E2*K*(Z2^3-Z1^3);
M3=(1/3)*b*E3*K*(Z1^3-Z0^3)+(1/2)*b*E3*D3*(Z0^2-Z1^2);
F1=(1/2)*b*E1*K*(Z3^2-Z2^2)-b*E1*D1*(Z3-Z2);
F2=(1/2)*b*E2*K*(Z2^2-Z1^2);
F3=(1/2)*b*E3*K*(Z1^2-Z0^2)-b*E3*D3*(Z1-Z0);
equ1=M1+M2+M3;
equ2=F1+F2+F3;
[K,Z0] = solve(equ1,equ2);
%2#
clc
clear
syms Z0 K ;
E1=30.336*1000;%Mpa
E2=69*1000; %AL(Mpa)
E3=E1;
D1=1350/1000000;
D3=-D1/3;
a=0.32; %mm
b=0.1:0.02:1;
n=length(b);
for i=1:n
Z1=Z0+a;
Z2=Z1+b(i);
Z3=Z2+a;
M1=(1/3)*b(i)*E1*K*(Z3^3-Z2^3)+(1/2)*b(i)*E1*D1*(Z2^2-Z3^2);
M2=(1/3)*b(i)*E2*K*(Z2^3-Z1^3);
M3=(1/3)*b(i)*E3*K*(Z1^3-Z0^3)+(1/2)*b(i)*E3*D3*(Z0^2-Z1^2);
F1=(1/2)*b(i)*E1*K*(Z3^2-Z2^2)-b(i)*E1*D1*(Z3-Z2);
F2=(1/2)*b(i)*E2*K*(Z2^2-Z1^2);
F3=(1/2)*b(i)*E3*K*(Z1^2-Z0^2)-b(i)*E3*D3*(Z1-Z0);
equ1=M1+M2+M3;
equ2=F1+F2+F3;
[x(i),y(i)] = solve(equ1,equ2); %X(i)=K(i),Y(i)=Z0(i)
end
x';
2#代码中把for i=1:n改为for i=1:3可以运行,但是改为for i=1:4或比4大的数就不能运行
但是将对应的b=0.16或b=0.18代入1#中单独求都可求出1组解
我是彻底懵了,到底咋回事啊,

matlab solve 求解方程组遇到Error using ==> subsasgn代码如下1#是没加循环时可以运行,2#是加循环是出现报错报错内容:Error using ==> subsasgnIn an assignment A(:) = B,the number of elements in A and Bmust be the same.Err
我把你程序直接贴到命令行没有报错啊?

matlab solve求解得到多余解一个方程组有唯一解(虽然方程很复杂,但是求解过程中刚好可以约掉一些项,可以推导出解析式),但是matlab的solve求出2组解,有遇到过这种情况的么?为什么? matlab 微分方程组求解 matlab求解以下微分方程组! 怎样用Matlab求解非线性方程组 用MATLAB求解方程组值 关于matlab解多元一次方程组的问题如果方程组中含有求和符号应该怎么求解?还是用solve函数吗? matlab solve 求解方程组算例遇到的问题1#和2#程序类似,1#运行没问题,但是2#运行会出现Error using ==> subsasgnSubscripted assignment dimension mismatch.Error in ==> sym.subsasgn at 33y = builtin('subsasgn',sx,a,b);请问问题 matlab solve 求解方程组遇到Error using ==> subsasgn代码如下1#是没加循环时可以运行,2#是加循环是出现报错报错内容:Error using ==> subsasgnIn an assignment A(:) = B,the number of elements in A and Bmust be the same.Err matlab解方程组,通常用solve还是用矩阵? Matlab中solve解非线性方程组用的是什么算法?能否查看solve的源程序? 这个微分方程组杂用matlab编程求解 matlab带参数的方程组求解 matlab怎么求解微分代数方程组 matlab矩阵求求解微分方程组{用matlab编程}数值求解微分方程组求程序 matlab常微分方程组的解法matlab怎么求一阶常微分方程组(solve做不出来的那种) matlab中solve函数solve函数最多可以解多少维的方程组,上千维的可以吗, matlab 解方程组系数问题如下:我先算出系数,然后求解可以得到解:[t,x,y]=solve('(x-2193.82160000000)^2+(y-1478.25070000000)^2=25',... '-7.47648319531258*t^3+0*t^2+151.200383195313*t+2193.82160000000=x',... '3.30035879077 在Matlab 中 使用solve函数求解二元二次方程组clcclear allsyms x yequation1=1351504793280023/309485009821345068724781056 - (y*conj(y))/4 - (252750694268921*3^(1/2)*x*y)/562949953421312 - (3*x*conj(x))/4 ;equation2=8059982666094291/9903520