help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: passing m-files as a function argument


From: parigigi
Subject: Re: passing m-files as a function argument
Date: Mon, 25 Jan 2010 01:40:51 -0800 (PST)

Thanks everybody...

I didn't manage to solve my problem because m-files that exit from this
commercial software are scripts and not functions, containing only data.
Using 

function []=NRW_libre(HFSSresultsfilename,epaisseur)

dataloading = str2func(HFSSresultsfilename)
dataloading;


I got the following error message:

??? Attempt to execute SCRIPT datamatrix as a function.


So I tried to use "load" function instead, but then I got the following
message:


Number of columns on line 3 of ASCII file C:\Documents and
Settings\Andrea\Bureau\mdesk\datamatrix.m must be the same as previous
lines.


I still didn't find a way to modify datamatrix.m in order to make it working
with the load command. Do you foresee any other solution?


Thanks a lot again

Andrea




Ben Abbott wrote:
> 
> On Friday, January 22, 2010, at 12:09PM, "David Grundberg"
> <address@hidden> wrote:
>>parigigi wrote:
>>> Hi everybody,
>>>
>>>
>>> I am currently using a commercial software that is giving me in output
>>> several m-files as a results of different simulations. I would like to
>>> do
>>> the same analysis on each m-files. So I want to write a function that
>>> accepts a filename as an argument. Lets suppose that I want to apply
>>> 'myanalysis' function on a single output m-file of this commercial
>>> software.
>>> I want something that allows me to do:
>>>
>>> myanalysis (output_m-file_name,parameter);
>>>
>>> At a certain point inside this function I want to load this m-file as
>>> following:
>>>
>>> output_m-file_name;
>>>
>>> ecc...
>>>
>>>
>>> I still don't understand how to pass a m-file name as an argument. I
>>> tried
>>> with quotas " ' ", without, with "@" but nothing worked... Where am I
>>> wrong?
>>>
>>>
>>> Thanks a lot to everyone
>>>   
>>
>>Is the output m-file a function file or a script file? If it's a script 
>>file you can load it by running eval('foobar') where yopu have a script 
>>file saved as foobar.m
>>
>>try something like
>>
>>function myanalysis (filename, parameter)
>>  name = filename(1:end-2)
>>  printf ("Running %s\n", name);
>>  eval (name)
>>
>>  ....
>>
>>endfunction
>>
>>in a file called myanalysis.m.
>>
>>You should then be able to run myanalysis ('foobar.m')
>>
>>Note that you need to have foobar.m in the Octave search path.
>>
>>hth
>>David
> 
> If you're calling an m-file as a function ...
> 
> function myanalysis (filename, parameter)
>   myfun = str2func (filename)
>   printf ("Running %s\n", filename);
>   result = myfun (...)
>   ....
> endfunction
> 
> Ben
> 
> 
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
> 
> 

-- 
View this message in context: 
http://old.nabble.com/passing-m-files-as-a-function-argument-tp27274725p27304144.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]