Error Matrix dimensions must agree
7 views (last 30 days)
I am getting "Matrix dimensions must agree" error while running the following codings in MatLab. From the first two equations I am getting error because of exp(f.*phi) part. If I remove this part, the code works fine. But I need to add this in both equations. In the last equation I am getting error due to the factor_c part. Could someone help me correcting the mistakes? Thanks
Star Strider on 5 Jul 2017
First, you need an operator here, I assume multiplication:
↑ ← INSERT ‘*’ HERE
What are ‘p_phi’ and ‘p_z’ here:
I do not see where you have defined them, and your function does not have any arguments. A function file will not pick up variables from your workspace as an anonymous function would.
More Answers (1)
KSSV on 5 Jul 2017
Your S and phi should be arrays with equal dimensions. In your code they are not same. You need to proceed like below.
N = 100 ; % can be changed
S = linspace(0,600,N) ;% S=0:600;
phi = linspace(0,pi/2,N) ;% phi=0:0.01:pi/2;