Error Plotting a function - Matrix Dimensions must agree

조회 수: 1 (최근 30일)
Hi,
I am new to MATLAB, I am getting the following error
"Error using / Matrix dimensions must agree.
Error in ParticleVelocityvsParticleSize (line 37)
VP1=M*((G*R*Stagnation_Temperature)/(1+((G-1)/2)*M^2))^0.5*((3*Cd*Gas_Density*x)/(2*Powder_Density*Powder_Size*10^(-6)))^0.5"
The code consists of getting the input of all the variables from the user. I need to plot the VP1 vs Powder_Size graph, with varying Powder_Size from 10 to 45.
Powder_Size=linspace(10,45,100)
VP1=M*((G*R*Stagnation_Temperature)/(1+((G-1)/2)*M^2))^0.5*((3*Cd*Gas_Density*x)/(2*Powder_Density*Powder_Size*10^(-6)))^0.5
plot(Powder_Size,VP1)
Can anyone please help me with this. Thanks in advance.
  댓글 수: 1
Mathieu NOE
Mathieu NOE 2021년 4월 2일
hello
the error comes from the fact that you are not using dot product or dot division in your expression;

댓글을 달려면 로그인하십시오.

채택된 답변

Shubham Khatri
Shubham Khatri 2021년 4월 6일
Hello,
The error occurs because the matrix you are trying to multiply are not compatible with each other for multiplication due to the difference in number of elements in each matrix. Please check the size of each matrx you are multiplying and see if they can be multiplied. Also, if they are compatible, there is a need to use '.' (element operation) . For more information, please see this documentation link.
Hope it helps

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by