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:
Integration using Matlab

Subject: Integration using Matlab

From: Subrata Chandra

Date: 16 Oct, 2010 20:58:19

Message: 1 of 2

Well, what i'm trying at is creating a *.m file which will define a function and then i wanna INTEGRATE the function from the command window by a call with suitable arguments using 'quadl' command(say). The function goes like-

function [F]=strain_time_newt(max_str)
estep=0.01;
E=5;
s=0.01:estep:max_str;
P=s./max_str;
F=(1-P)./(1-E.*s.*(1-P));
end

Command Window :
>>strain_time_newt(2.0);

>>quadl(@strain_time_newt,0,10);

However, the integration couldn't be carried out and an attempt in doing so gives the message


??? Error using ==> rdivide
Matrix dimensions must agree.

Error in ==> strain_time_newt at 13
P=s./max_str;

Error in ==> quadl at 64
y = feval(f,x,varargin{:}); y = y(:).';

how am i going to get over this problem? please suggest.

Subject: Integration using Matlab

From: Roger Stafford

Date: 16 Oct, 2010 23:43:04

Message: 2 of 2

Subrata Chandra <subrata.chandra27@gmail.com> wrote in message <787449167.118709.1287262729375.JavaMail.root@gallium.mathforum.org>...
> Well, what i'm trying at is creating a *.m file which will define a function and then i wanna INTEGRATE the function from the command window by a call with suitable arguments using 'quadl' command(say). The function goes like-
>
> function [F]=strain_time_newt(max_str)
> estep=0.01;
> E=5;
> s=0.01:estep:max_str;
> P=s./max_str;
> F=(1-P)./(1-E.*s.*(1-P));
> end
>
> Command Window :
> >>strain_time_newt(2.0);
>
> >>quadl(@strain_time_newt,0,10);
>
> However, the integration couldn't be carried out and an attempt in doing so gives the message
>
>
> ??? Error using ==> rdivide
> Matrix dimensions must agree.
>
> Error in ==> strain_time_newt at 13
> P=s./max_str;
>
> Error in ==> quadl at 64
> y = feval(f,x,varargin{:}); y = y(:).';
>
> how am i going to get over this problem? please suggest.
- - - - - - - -
   Your m-file is not properly prepared. The function that is passed to it must be able to accept a vector of integrand values that 'quadl' chooses and to do so many times during a single integration process, not the scalar you have apparently assumed here. It looks as though you are trying to decide for 'quadl' what integration variable values it should use. That is not how 'quadl' works. It is not clear what function your integrand is, but whatever it is, you should write your function so that it can produce vector-valued integrand values corresponding to the vector of integration variable values passed to it. Read the documentation!

Roger Stafford

Tags for this Thread

No tags are associated with 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