How do i resolve this error

1 回表示 (過去 30 日間)
Olufemi Ologun
Olufemi Ologun 2022 年 1 月 17 日
コメント済み: Rik 2022 年 1 月 17 日
Error using .*
Matrix dimensions must agree.
Error in phdegmninvert (line 97)
up=-(fftbou.*(exp((z0*100000)*(frequencytotal.*(1/100000)))));

回答 (2 件)

Max Heimann
Max Heimann 2022 年 1 月 17 日
編集済み: Max Heimann 2022 年 1 月 17 日
Try turning the multiplication in the middle into an elementwise multiplication aswell.
Also, the last multiplication probably shouldnt be elementwise since you are multiplying with a scalar value
up=-(fftbou.*(exp((z0*100000) .* (frequencytotal*(1/100000)))));
If that does not work, we would need more information about the dimensions of the multiplied elements.
  1 件のコメント
Olufemi Ologun
Olufemi Ologun 2022 年 1 月 17 日
Thank you for the response.
I tried it but still given same error

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


Rik
Rik 2022 年 1 月 17 日
You can resolve this error by making sure the dimensions agree.
If you think this answer is unhelpful; it is. If you want a more helpful answer you will have to provide more details.
An element-wise multiplication will work if isequal(size(A),size(B)). If non-matching dimensions are of length 1 and you are using R2016b or later, implicit expansion will cause expansion into an array:
A=rand(1,3);
B=rand(4,1);
size(A.*B)
ans = 1×2
4 3
  3 件のコメント
Olufemi Ologun
Olufemi Ologun 2022 年 1 月 17 日
still need advice.
thank you
Rik
Rik 2022 年 1 月 17 日
Is that the size, or the content? If it is the latter there should be no issue (except maybe what Max already wrote about the * instead of .*). If the former, how do you expect Matlab to multiply them? What should be the result of this?
[1 2;3 4].*[1 2 3;4 5 6;7 8 9]

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

カテゴリ

Help Center および 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