Hi there,
First of all, thanks so much to everyone who has been helping me with my code so far; you have been so helpful!
Okay, now that i have my code working nicely i want to run it several times in a row with various input parameters. My function analyzes data and outputs a struct based on the input parameters and I want to have it provide output for several different inputs.
In the command console it would look like this:
>> interval_1min = myFunction(1)
>> interval_2min = myFunction(2)
>> interval_3min = myFunction(3)
..
..
..
and I want to do this for a bunch of different inputs but each time it takes about 2hrs so I want it to do a bunch of them overnight. I hope this is clear. I'm pretty sure it is simple to do this with an m-file or something but I am a MATLAB beginner so I dont know the best way to go about it.
Thanks in advance!!
|
|
0
|
|
|
|
Reply
|
Adam
|
7/27/2010 12:07:03 AM |
|
On Jul 27, 12:07=A0pm, "Adam Thibideau" <adam.thibid...@gmail.com>
wrote:
> Hi there,
>
> First of all, thanks so much to everyone who has been helping me with my =
code so far; you have been so helpful!
>
> Okay, now that i have my code working nicely i want to run it several tim=
es in a row with various input parameters. =A0My function analyzes data and=
outputs a struct based on the input parameters and I want to have it provi=
de output for several different inputs.
>
> In the command console it would look like this:
>
> >> interval_1min =3D myFunction(1)
> >> interval_2min =3D myFunction(2)
> >> interval_3min =3D myFunction(3)
>
> .
> .
> .
>
> and I want to do this for a bunch of different inputs but each time it ta=
kes about 2hrs so I want it to do a bunch of them overnight. =A0I hope this=
is clear. =A0I'm pretty sure it is simple to do this with an m-file or som=
ething but I am a MATLAB beginner so I dont know the best way to go about i=
t.
>
> Thanks in advance!!
Don't do this!!
Read this:
http://matlabwiki.mathworks.com/MATLAB_FAQ#How_can_I_create_variables_A1.2C=
_A2.2C....2CA10_in_a_loop.3F
|
|
0
|
|
|
|
Reply
|
TideMan
|
7/27/2010 12:46:19 AM
|
|
> Don't do this!!
>
> Read this:
> http://matlabwiki.mathworks.com/MATLAB_FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F
Thats not what i want though. I want the output from each iteration of my function to be assigned to a variable. I want to have the code get executed overnight just as if I was sitting beside the computer and typing in the next command when the previous one finished. Understand?
|
|
0
|
|
|
|
Reply
|
Adam
|
7/27/2010 1:09:04 AM
|
|
"Adam Thibideau" <adam.thibideau@gmail.com> wrote in message <i2lbjf$ie1$1@fred.mathworks.com>...
>
> > Don't do this!!
> >
> > Read this:
> > http://matlabwiki.mathworks.com/MATLAB_FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F
>
>
> Thats not what i want though. I want the output from each iteration of my function to be assigned to a variable. I want to have the code get executed overnight just as if I was sitting beside the computer and typing in the next command when the previous one finished. Understand?
How about a while or for loop that just loops the number of functions or whatever you want to do? Each loop, you could be reading an input with your function parameters. Make sure that for ever output, you save it (use save for variables or saveas for figures) and close it, or else MATLAB will get bogged down quickly.
|
|
0
|
|
|
|
Reply
|
Judy
|
7/27/2010 1:37:03 AM
|
|
On Jul 27, 1:09=A0pm, "Adam Thibideau" <adam.thibid...@gmail.com> wrote:
> > Don't do this!!
>
> > Read this:
> >http://matlabwiki.mathworks.com/MATLAB_FAQ#How_can_I_create_variables...
>
> Thats not what i want though. =A0I want the output from each iteration of=
my function to be assigned to a variable. =A0I want to have the code get e=
xecuted overnight just as if I was sitting beside the computer and typing i=
n the next command when the previous one finished. =A0Understand?
I understand, but what I'm saying is that you should NOT assign the
output to variables defined like that. And I gave you that reference
in the FAQ because it not only shows how to assign variables
correctly, but also shows a for loop, which is what you're looking
for.
Did you not grasp that when you read the FAQ?
|
|
0
|
|
|
|
Reply
|
TideMan
|
7/27/2010 2:15:42 AM
|
|
No sorry I did not. Maybe if you would have offered a little more explaination to your solution than "dont do this" i would have grasped it.
|
|
0
|
|
|
|
Reply
|
Adam
|
7/27/2010 2:34:05 AM
|
|
To be even more explicit, do something like this:
% pre-allocation goes here.
for ii = 1:5
interval(ii).min = min(rand(ii)); % For example
end
% Now look at: interval(4).min
OR this:
% pre-allocation goes here.
for ii = 1:5
interval_min{ii} = min(rand(ii)); % For example
end
% Now look at: interval_min{4}
|
|
0
|
|
|
|
Reply
|
Matt
|
7/27/2010 2:39:04 AM
|
|
Adam Thibideau wrote:
> No sorry I did not. Maybe if you would have offered a little more
> explaination to your solution than "dont do this" i would have grasped it.
In your opinion, how long of a tutorial should we write in response to
each of the several hundred questions posted each day?
|
|
0
|
|
|
|
Reply
|
Walter
|
7/27/2010 3:30:10 AM
|
|
Just a passing thought: If your code works in serial fashion, why don't you consider PARFORing it?
http://www.mathworks.com/access/helpdesk/help/toolbox/distcomp/brb2x2l-1.html
Thanks,
Saurabh
|
|
0
|
|
|
|
Reply
|
Saurabh
|
7/28/2010 10:18:21 PM
|
|
"Adam Thibideau" <adam.thibideau@gmail.com> wrote in message <i2lgis$7d9$1@fred.mathworks.com>...
> No sorry I did not. Maybe if you would have offered a little more explaination to your solution than "dont do this" i would have grasped it.
You should try to digest the FAQ, the answer you received was the correct one. It is hard to manipulate variables if you create them in the way you describe. You will end up having to use the eval function, which is really not ideal. If you index as suggested then your code will be more elegant, compact and easy to understand. It will also make it easier to extract the data which you want.
|
|
0
|
|
|
|
Reply
|
Rob
|
7/28/2010 11:30:25 PM
|
|
|
9 Replies
250 Views
(page loaded in 0.235 seconds)
Similiar Articles: How to execute my code over and over?? - comp.soft-sys.matlab ...Hi there, First of all, thanks so much to everyone who has been helping me with my code so far; you have been so helpful! Okay, now that i have ... Need 1D shallow water equation matlab code - comp.soft-sys.matlab ...Savitzky-Golay filtering and endpoint issues - comp.soft-sys ... Matlab code for local averaging - comp.soft-sys.matlab Savitzky-Golay filtering and endpoint issues ... How to estimate exectution time - comp.soft-sys.matlab... and, in a finite time, determine how long the second program will take to run over ... I think I should reconstruct my code in more effecient way and test for less no. of ... (Ham Radio) How to run RTTY on C64 / VIC 20 ? - comp.sys.cbm ...Greetings CBM crew, I was wondering if anyone here has experience with ham radio and has used a VIC 20 or C64 to send and receive RTTY over the a... Runtime.exec help please - comp.lang.java.programmerI am trying to use Runtime.exec to run a command and ... but cannot get it to >> work.>>>> E.g>>>> My code says ... ProcessBuilder class, it gives you> more control over ... Remote Execution of Local Code - comp.soft-sys.matlabHello, for a large number of reasons I'm trying to find a way to execute code on a remote RHEL 6.0 Linux machine from a local OSX machine over a netwo... improve strlen - comp.lang.asm.x86When you run 1,000,000 strings through your xstrlen function, you're hammering on the same code over and over again and even ... the result is the same time > my code and ... OCEAN: Returning from paramRun() command using distributed ...The paramRun() function does not return until the run is over, and then the script ... is an annoying workaround, because I have to maintain certain parts of the code ... Unable to execute shell script - comp.unix.solarisBTW, the failing over is done by the shell and not the kernel so it's something that ... execute shell script - comp.unix.solaris How can I get a Javascript command to run a ... How to separate command line args - comp.lang.rexxDoes anyone have some simple code to handle this ? ... to the "nibble method" where args is cut down over and ... txt\" Secondly, surely all one needs to do is to run a ... How to execute my code over and over?? - comp.soft-sys.matlab ...Hi there, First of all, thanks so much to everyone who has been helping me with my code so far; you have been so helpful! Okay, now that i have ... FAQ - AutoIt WikiThen if you run the script (uncompiled as an AU3 file), you can mouse over the AutoIt icon in the system tray ... Me", "I Have A Problem", "Question", "Help me fix my code ... 7/23/2012 2:59:17 PM
|