Clear Filters
Clear Filters

Error Plotting a function - Matrix Dimensions must agree

2 views (last 30 days)
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 Comment
Mathieu NOE
Mathieu NOE on 2 Apr 2021
hello
the error comes from the fact that you are not using dot product or dot division in your expression;

Sign in to comment.

Accepted Answer

Shubham Khatri
Shubham Khatri on 6 Apr 2021
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

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!