|
On Jan 12, 5:47 am, "Pink Panther " <huguesria...@gmail.com> wrote:
> "Oleg Komarov" <oleg.komarovRemove.t...@hotmail.it> wrote in message <igi0ka$dt...@fred.mathworks.com>...
> > "Pink Panther" wrote in message <ighv97$ge...@fred.mathworks.com>...
> > > hi,
> > > I am trying to create a function to be called from other part of the code. it begins like this :
>
> > > function createfigure(data,param,synthese,resultats)
>
> > > %% convert time from excel format to decimal format
> > > if data(1,1)>2500
> > > startd=dateve
> > > etc.
> > > etc.
>
> > > this gives an error message on line "if data(1,1) ...", saying that data is not known while if I type data in the command window, data is here ok. what's happening ? thanks in advance
>
> > You're not telling everything. I dont' get (obviously) any problem.
> > Can you post the whole error message please.
>
> > Oleg
>
> here is the code :
> function createfigure(data, param, synthese, resultats)
>
> %% convert time from excel format to decimal format
> if data(1,1)>2500
> startd=datevec(data(1,1));
> startynum=datenum([startd(1) 1 1 0 0 0]);
> if startd(1)>15
> starty=1900+startd(1);
> else
> starty=2000+startd(1);
> end
> t(:,1)=starty*ones(length(data),1)+(data(:,1)-startynum)/365.25;
> else
> t=data(:,1);
> end
>
> here is the error generated on these few lines of code :
> "Matlab Editor"
> "The selected cell cannot be evaluated beacuse it contains an invalid argument"
>
> as the code aforementionned works perfectly well in another program I wrote, I assume the problem comes from the data itself.
You're trying to run this from within the Editor by clicking Evaluate
Cell, but when you do this, it has no input arguments defined.
Evaluate Cell only works in a script, not a function.
You need to either: go to the Command Window and call it with
arguments; or write a script that calls the function, then execute
using Evaluate Cell.
|