matlab计算时出现“ Error using ==> mpower Inputs must be a scalar...
发布网友
发布时间:2023-12-29 18:53
我来回答
共1个回答
热心网友
时间:2024-03-29 00:16
首先,你的j1和j3没有赋值。我任意给了一个值,j1=1;j3=3。
其次,你的a、b和r的赋值中逗号要用英文而非中文,我做了修改。a =[-0.0881,-2.1214,-1.4637,-3.4110,-2.0793]; b =[0.1527,0.3555,0.4291,0.1678,0.3078]; r =[-0.0963,-0.3700,-0.0963,-0.2179,-0.3438];
再次(关键问题),矩阵乘积或乘幂,如果要求的是对应元素的乘积,需要用点乘,即在称号或乘幂符号前加一个点。
程序如下:
a =[-0.0881,-2.1214,-1.4637,-3.4110,-2.0793];
b =[0.1527,0.3555,0.4291,0.1678,0.3078];
r =[-0.0963,-0.3700,-0.0963,-0.2179,-0.3438];
j1=1;j3=3;
J=[(a.^2)*j3+(b.^2)*j1-a.*b.*r]./[(a.^2)+(b.^2)]
W=a.*[(b.^2)*j3-(b.^2)*j1+a.*b.*r]./[b.*(a.^2)+(b.^2)]