Error in Intergral with error matrix dimensions must agree.

xbar = [0.2 0.4 0.6 0.8]; tbar = [0:0.001:2]; xsbar = 2.*tbar - tbar.^2;
for i=1:length(tbar) if xbar(1) <= xsbar(i) hbar(i) = ((xbar(1) - xsbar(i))^2)/ (9*(tbar(i)^2)); ubar(i) = (2/3)* (1 - 2*tbar(i) + (xbar(1)/tbar(i))); else hbar(i) = 0; ubar(i) = 0; end end v = length(hbar); fun = @(z) ubar(z); uavg = 1/hbar * integral(fun,0,v,'ArrayValued',true)
Error: Error using / Matrix dimensions must agree.

 Accepted Answer

Use "trapz" instead of "integral".
Best wishes
Torsten.

More Answers (0)

Asked:

on 21 Apr 2016

Answered:

on 21 Apr 2016

Community Treasure Hunt

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

Start Hunting!