From: Paulo on
Hello all,

I am trying to make a central .m file where I can choose between some equation (that should be each in a separated me file) and choose between some method to solve it (Euler, RKutta, etc).

So I need one .m file that depending on some parameter value I will solve a choosed equation by the choosed algotihm (also the algotihm should be determined by a second parameter value).

In a second moment I'll try to put this in a GUI interface.

Well, I tried some commands and the matlab help , but after a couple of hours I figure out that I was looking at the wrong commands...

Thank you all for the help.

Paulo.
From: Prediger on
The best way to explain how you can declare an m file is through an example:

Declared m file:

function [output1,output2…] = funname(input1)

output1 = input1^2;
output2 = input1^3+8;

in the center m file you shall just simply copy the name of the function '[output1,output2…] = funname(input1)' into the body part

hope helped
From: Steven Lord on

"Paulo " <biomar1(a)yahoo.com.br> wrote in message
news:hiethj$bda$1(a)fred.mathworks.com...
> Hello all,
>
> I am trying to make a central .m file where I can choose between some
> equation (that should be each in a separated me file) and choose between
> some method to solve it (Euler, RKutta, etc).
>
> So I need one .m file that depending on some parameter value I will solve
> a choosed equation by the choosed algotihm (also the algotihm should be
> determined by a second parameter value).
>
> In a second moment I'll try to put this in a GUI interface.
>
> Well, I tried some commands and the matlab help , but after a couple of
> hours I figure out that I was looking at the wrong commands...
>
> Thank you all for the help.
>
> Paulo.

A hint:

function y = selectAFunction(n, x)
% Calling syntax:
%
% y = selectAFunction(2, 0:0.1:1)

functionsToRun = {@sin, @cos, @tan, @exp};
% Add error checking for n here to make sure
% it's an integer value between 1 and numel(functionToRun)
y = functionsToRun{n}(x);

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


From: Paulo on
Thank you guys. Worked very well. So I've gone to try with ode solving between diferent functions. But now I got stucked again:

Iam still trying to solve diferent odes changing one parameter:
Suppose I want to solve using ode23, one function, wich I need to choose, and let select.m be the calling sintax:

y = selectAFunction(n);

Iam trying to use

[t,y] = ode23(@select, tspan, ci);

to solve one of my differentials equations (each a diferent function) pointed at "selectAFunction" by a parameter at select.m

Well, looks confuse, but I have now idea how to get better. Please help ! :-)

THanks again!


"Steven Lord" <slord(a)mathworks.com> wrote in message <hiffci$dmd$1(a)fred.mathworks.com>...
>
> "Paulo " <biomar1(a)yahoo.com.br> wrote in message
> news:hiethj$bda$1(a)fred.mathworks.com...
> > Hello all,
> >
> > I am trying to make a central .m file where I can choose between some
> > equation (that should be each in a separated me file) and choose between
> > some method to solve it (Euler, RKutta, etc).
> >
> > So I need one .m file that depending on some parameter value I will solve
> > a choosed equation by the choosed algotihm (also the algotihm should be
> > determined by a second parameter value).
> >
> > In a second moment I'll try to put this in a GUI interface.
> >
> > Well, I tried some commands and the matlab help , but after a couple of
> > hours I figure out that I was looking at the wrong commands...
> >
> > Thank you all for the help.
> >
> > Paulo.
>
> A hint:
>
> function y = selectAFunction(n, x)
> % Calling syntax:
> %
> % y = selectAFunction(2, 0:0.1:1)
>
> functionsToRun = {@sin, @cos, @tan, @exp};
> % Add error checking for n here to make sure
> % it's an integer value between 1 and numel(functionToRun)
> y = functionsToRun{n}(x);
>
> --
> Steve Lord
> slord(a)mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
>
From: Paulo on
Help !!!!

"Paulo " <biomar1(a)yahoo.com.br> wrote in message <hild11$t8a$1(a)fred.mathworks.com>...
> Thank you guys. Worked very well. So I've gone to try with ode solving between diferent functions. But now I got stucked again:
>
> Iam still trying to solve diferent odes changing one parameter:
> Suppose I want to solve using ode23, one function, wich I need to choose, and let select.m be the calling sintax:
>
> y = selectAFunction(n);
>
> Iam trying to use
>
> [t,y] = ode23(@select, tspan, ci);
>
> to solve one of my differentials equations (each a diferent function) pointed at "selectAFunction" by a parameter at select.m
>
> Well, looks confuse, but I have now idea how to get better. Please help ! :-)
>
> THanks again!
>
>
> "Steven Lord" <slord(a)mathworks.com> wrote in message <hiffci$dmd$1(a)fred.mathworks.com>...
> >
> > "Paulo " <biomar1(a)yahoo.com.br> wrote in message
> > news:hiethj$bda$1(a)fred.mathworks.com...
> > > Hello all,
> > >
> > > I am trying to make a central .m file where I can choose between some
> > > equation (that should be each in a separated me file) and choose between
> > > some method to solve it (Euler, RKutta, etc).
> > >
> > > So I need one .m file that depending on some parameter value I will solve
> > > a choosed equation by the choosed algotihm (also the algotihm should be
> > > determined by a second parameter value).
> > >
> > > In a second moment I'll try to put this in a GUI interface.
> > >
> > > Well, I tried some commands and the matlab help , but after a couple of
> > > hours I figure out that I was looking at the wrong commands...
> > >
> > > Thank you all for the help.
> > >
> > > Paulo.
> >
> > A hint:
> >
> > function y = selectAFunction(n, x)
> > % Calling syntax:
> > %
> > % y = selectAFunction(2, 0:0.1:1)
> >
> > functionsToRun = {@sin, @cos, @tan, @exp};
> > % Add error checking for n here to make sure
> > % it's an integer value between 1 and numel(functionToRun)
> > y = functionsToRun{n}(x);
> >
> > --
> > Steve Lord
> > slord(a)mathworks.com
> > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> >