|
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
|