Error message - matrix dimensions must agree
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (2)
Chris C
am 13 Mär. 2014
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).
1 Kommentar
Chris C
am 13 Mär. 2014
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 Kommentare
Chris C
am 13 Mär. 2014
No problem. Please don't forget to "Accept" an answer that satisfactorily answers your question. :)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!