My code continuously giving this error( Error using ./ Matrix dimensions must agree. Error in Untitled14 (line 16) k = zeta*(w./wd); )

zeta = g * q;
j= 1-power(zeta,2);
wd = w*power(j,1/2);
r=w./wd;
k = zeta*r;
l=k*sin(wd*t);
m=cos(wdt) + l;
n= - zeta*w*t;
p = 1 - exp(n)*(m);
plot (p)

4 件のコメント

Walter Roberson
Walter Roberson 2017 年 6 月 11 日
That line, k = zeta*(w./wd); does not appear in your posted code.
It is difficult for us to debug this without knowing the size() of each of the variables.
arif hussain
arif hussain 2017 年 6 月 12 日
編集済み: Walter Roberson 2017 年 6 月 14 日
basically this is the full code and the problem in variable "r" r=w./wd; and cant we assume the maximum size of the variable?
filename = 'datacollect2.xlsx';
num = xlsread(filename,'B1:B60');
w = num/60;
N = length(num);
t = 1/w;
s = xlsread(filename,'B3:B3');
xt= s;
g = 1/N;
i = xt + num;
h = xt/ i ;
ln=@log;
q=ln(h);
zeta = g * q;
j= 1-power(zeta,2);
wd = w*power(j,1/2);
r=w./wd;
k = zeta*r;
l=k*sin(wd*t);
m=cos(wdt) + l;
n= - zeta*w*t;
p = 1 - exp(n)*(m);
plot (p)
filename = 'datacollect2.xlsx';
num = xlsread(filename,'B1:B60');
w = num/60;
N = length(num);
t = 1/w;
s = xlsread(filename,'B3:B3');
xt= s;
g = 1/N;
i = xt + num;
h = xt/ i ;
ln=@log;
q=ln(h);
zeta = g * q;
j= 1-power(zeta,2);
wd = w*power(j,1/2);
r=w./wd;
k = zeta*r;
l=k*sin(wd*t);
m=cos(wdt) + l;
n= - zeta*w*t;
p = 1 - exp(n)*(m);
plot (p)
arif hussain
arif hussain 2017 年 6 月 12 日
Error using ./ Matrix dimensions must agree.
Error in Untitled14 (line 16) r=w./wd;
arif hussain
arif hussain 2017 年 6 月 12 日
size of w is 60x1 double size of wd is 60x60 double

サインインしてコメントする。

 採用された回答

You are using the / operator in several places. In MATLAB, A/B is more or less the same as A * pinv(B) . 1/w where w is 60 x 1, gives you a 1 x 60 result. Likewise, h = xt/ i where i is 60 x 1, gives you a 1 x 60 result. You then end up working with this mix of 60 x 1 and 1 x 60 and you end up with trying to combine arrays in the wrong way.
>> 1/[2;4;3]
ans =
0 0.25 0
Notice the output is a row vector for a column vector divisor.
If you would need the answer [0.5; 0.25; 0.3333] (column vector, individual divisions) instead for this calculation, then you need to use the ./ operator

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by