matlab 提示说内矩阵维度不一致。
方程:functiony=f(m1,m2,j)g=9.8;y=[0,m1*g,0,m2*g]'*inv([m1*cos(j),-m1,-sin(j),0;m1*sin(j...
方程:
function y=f(m1,m2,j)
g=9.8;
y=[0,m1*g,0,m2*g]'*inv([m1*cos(j),-m1,-sin(j),0;m1*sin(j),0,cos(j),0;0,m2,-sin(j),0;0,0,-cos(j),1])
y
结果:
>> hanshu(12,12,8)
??? Error using ==> mtimes
Inner matrix dimensions must agree.
Error in ==> hanshu at 3
y=[0,m1*g,0,m2*g]'*inv([m1*cos(j),-m1,-sin(j),0;m1*sin(j),0,cos(j),0;0,m2,-sin(j),0;0,0,-cos(j),1])
>> 展开
function y=f(m1,m2,j)
g=9.8;
y=[0,m1*g,0,m2*g]'*inv([m1*cos(j),-m1,-sin(j),0;m1*sin(j),0,cos(j),0;0,m2,-sin(j),0;0,0,-cos(j),1])
y
结果:
>> hanshu(12,12,8)
??? Error using ==> mtimes
Inner matrix dimensions must agree.
Error in ==> hanshu at 3
y=[0,m1*g,0,m2*g]'*inv([m1*cos(j),-m1,-sin(j),0;m1*sin(j),0,cos(j),0;0,m2,-sin(j),0;0,0,-cos(j),1])
>> 展开
1个回答
展开全部
[0,m1*g,0,m2*g]'
不要转置,直接[0,m1*g,0,m2*g]就好
不要转置,直接[0,m1*g,0,m2*g]就好
追答
矩阵乘法规定的,第一个阵的列数必须与第二个阵的行数一致,否则matlab就提示出错。
不转置的话[0,m1*g,0,m2*g]是一个1行四列的向量
刚看了看原题,是不是为了求解X写的函数?
X=inv(A)*B,
矩阵乘法可没有交换律
try
y=inv([m1*cos(j),-m1,-sin(j),0;m1*sin(j),0,cos(j),0;0,m2,-sin(j),0;0,0,-cos(j),1])*[0,m1*g,0,m2*g]'
光点科技
2023-08-15 广告
2023-08-15 广告
通常情况下,我们会按照结构模型把系统产生的数据分为三种类型:结构化数据、半结构化数据和非结构化数据。结构化数据,即行数据,是存储在数据库里,可以用二维表结构来逻辑表达实现的数据。最常见的就是数字数据和文本数据,它们可以某种标准格式存在于文件...
点击进入详情页
本回答由光点科技提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询