Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Help with Matlab - trapz function

Subject: Help with Matlab - trapz function

From: Niket

Date: 13 Mar, 2012 22:59:17

Message: 1 of 2

function X = quiz(a)
a = [0.001:1e-6:0.05];
b = .100;
A = pi.*a./(2.*b);
P = sqrt(tan(A)./A);
Q = 0.752 + 2.02.*a./b + 0.37.*(1 - sin(A)).^3;
R = cos(A);
Y = P.*Q./R;

C = 8.20*10^-13;
m = 3.5;
S = 500;
X = 1./(C.*(S.*Y).^m);
trapz(a,X);
end

I keep getting an output that is not a single number but an array. I don't know how to evaluate this integral using the trapz function and I can't find any more help... Thanks for all the help!!

Subject: Help with Matlab - trapz function

From: Sadik

Date: 13 Mar, 2012 23:14:19

Message: 2 of 2

Niket,

You are getting X as the output, this is why. You should instead get the result of trapz as follows:

function I = quiz()
....
....
I = trapz(a,X);

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us