For Programmers: Free Programming Magazines  


Home > Archive > Matlab > April 2005 > Integration in Matlab









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Integration in Matlab
Taji

2005-04-22, 4:04 pm

Hi there!

I am a novice user in Matlab. The problem I am facing is that I have
a complicated model with complex numbers (impedances etc.). The end
result is reached by a number of substitutions from the previously
calculated expressions. In a nutshell, it forms a really long chain
of expressions.

Under these circumstances I want to integrate the final expression
with respect to single variable (frequency). How do I do that?

There is no easy way that I can express this expression as Matlab
help says:

function y = myfun(x)
y = 1./(x.^3-2*x-5);
Q = quad(@myfun,0,2)

It won't be easy to express this expression in terms of the frequency
alone.....

Any tips? After all, all I am asking Matlab to do is to plot this
expression vs. frequency and then calculate the area under the
curve.... but I am stuck.... :(

With best regards,

Taji
Jen

2005-04-22, 9:00 pm

Taji wrote:
>
>
> Hi there!
>
> I am a novice user in Matlab. The problem I am facing is that I
> have
> a complicated model with complex numbers (impedances etc.). The end
> result is reached by a number of substitutions from the previously
> calculated expressions. In a nutshell, it forms a really long chain
> of expressions.
>
> Under these circumstances I want to integrate the final expression
> with respect to single variable (frequency). How do I do that?
>
> There is no easy way that I can express this expression as Matlab
> help says:
>
> function y = myfun(x)
> y = 1./(x.^3-2*x-5);
> Q = quad(@myfun,0,2)
>
> It won't be easy to express this expression in terms of the
> frequency
> alone.....
>
> Any tips? After all, all I am asking Matlab to do is to plot this
> expression vs. frequency and then calculate the area under the
> curve.... but I am stuck.... :(
>
> With best regards,
>
> Taji


Depending on simplicity of the shape of expression vs. frequency, you
could approximate integral yourself directly. Compute expression for
a range of closely spaced frequencies. Sum result and multiply by
the space between frequencies. Repeat with smaller df as needed.
There are plenty of cases, however, when you have to be more sneaky
about the order in which you do the sum and so forth.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com