Error message - matrix dimensions must agree
4 ビュー (過去 30 日間)
古いコメントを表示
Hi I am inputting the following line of code to solve a laplace irreducible quadratic equation. Its quite long and I have checked the brackets numerous times and I think they are correct. I think the problem is arising due to the use of the multiplication sign and I am unsure where I need to use the .* and the *. Could someone please advise? Thank you.
i=(c/b)*((1-(exp((-a/2)*t))).*cos(sqrt(b-((a^2)/4))*t)+(a/2)*(1/(sqrt(b-(a^2)/4).*t))*sin(sqrt(b-(a^2)/4)*t));
I then get the following error message
Error using / Matrix dimensions must agree.
Error in laplace (line 104) i=(A)*((1-(exp((-a/2)*t))).*cos(sqrt(b-((a^2)/4))*t)+(a/2)*(1/(sqrt(b-(a^2)/4).*t))*sin(sqrt(b-(a^2)/4)*t));
0 件のコメント
回答 (2 件)
Chris C
2014 年 3 月 13 日
The .* is used whenever you have to arrays or matrices that you want to multiply each individual element with the corresponding element in the other array or matrix. * is used when you want good old fashioned matrix muliplication. For me to be more clear I need to know what the variables in your code stand for (i.e. arrays, constants, matrices).
Chris C
2014 年 3 月 13 日
Okay, I found them (I think). In line 104 that you reference above it looks like there are several variables referenced: A,a,t and b. A, a and b are all contants and t is your only array. Therefore every instance of t multiplied or divided by itself needs a . before the operation.
I found one instance that hasn't been done correctly i.e...
(1/(sqrt(b-(a^2)/4).*t))*(sin(sqrt(b-(a^2)/4).*t))))
There needs to be a . between these two terms and it should look like this...
(1/(sqrt(b-(a^2)/4).*t)).*(sin(sqrt(b-(a^2)/4).*t))))
Hope that helps.
2 件のコメント
Chris C
2014 年 3 月 13 日
No problem. Please don't forget to "Accept" an answer that satisfactorily answers your question. :)
参考
カテゴリ
Help Center および File Exchange で Axis Labels についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!