- #1
sarrfriend
- 6
- 0
Hi,
I tried to numerically integrate an equation in MATLAB using the trapezium method. Here is the code that I wrote:
ao = 1;
X = 0:ao/10:ao;
Y = 1/sqrt((power(Ho,2)*((O_m*power(X,-1))+(O_r*power(X,-2))+(O_l*power(X,2))))-(k*power(c,2)));
age = trapz(X,Y);
where the values for O_m, O_r, O_l and k were obtained using input(). When I executed the above code, I get "Error using / Matrix dimensions must agree."
Can you tell me what the problem is?
Sarrvesh
I tried to numerically integrate an equation in MATLAB using the trapezium method. Here is the code that I wrote:
ao = 1;
X = 0:ao/10:ao;
Y = 1/sqrt((power(Ho,2)*((O_m*power(X,-1))+(O_r*power(X,-2))+(O_l*power(X,2))))-(k*power(c,2)));
age = trapz(X,Y);
where the values for O_m, O_r, O_l and k were obtained using input(). When I executed the above code, I get "Error using / Matrix dimensions must agree."
Can you tell me what the problem is?
Sarrvesh