From: jeff on
HOw can I rewrite this as one statement:

mSim(a,b,c,1) = [vO1(a), vO2(b), vO3(c), vP(1)];
mSim(a,b,c,2) = [vO1(a), vO2(b), vO3(c), vP(2)];
mSim(a,b,c,3) = [vO1(a), vO2(b), vO3(c), vP(3)];
mSim(a,b,c,4) = [vO1(a), vO2(b), vO3(c), vP(4)];

All that changes is the last entry... im dumb help!
-Jeff
From: Guillermo on
For this specific problem, with only 4 values of msimulations, you can do it
in one line:

mSimulations(a,b,c,1:4) = [vAvg(1) vSTD(1) vAvg(2) vSTD(2)]

However, if you have a lot more values, and you dont want to type them
individually, you could do it in two lines with no loops..
for example this longer set:
mSimulations(a,b,c,1) = vAvg(1);
mSimulations(a,b,c,2) = vSTD(1);
mSimulations(a,b,c,3) = vAvg(2);
mSimulations(a,b,c,4) = vSTD(2);
mSimulations(a,b,c,5) = vAvg(3);
mSimulations(a,b,c,6) = vSTD(3);
mSimulations(a,b,c,7) = vAvg(4);
mSimulations(a,b,c,8) = vSTD(4);

can be replaced by

mSimulations(a,b,c,1:2:7) = vAvg(1:4);
mSimulations(a,b,c,2:2:8) = vSTD(1:4);

and works with two lines for any number of values.

tell me how it went




"jef" <REM(a)REM.REM> wrote in message news:eefc30f.1(a)webx.raydaftYaTP...
> sorry im even DUMBEr, i meant, how do i rewrite:
>
> mSimulations(a,b,c,1) = vAvg(1);
> mSimulations(a,b,c,2) = vSTD(1);
> mSimulations(a,b,c,3) = vAvg(2);
> mSimulations(a,b,c,4) = vSTD(2);


From: jeff on
hi all, thanks for the responses. Im actually dont have matlab again
till the afternoon tomorrow, but I had tried Guillermo's solution
(actually something equivalent to it) and it didn't work but gave me
some random error. I'll try the newer ones out tomorrow. Thanks.
From: Guillermo on
that solution will actually do:
> mSimulations(a,b,c,1) = vAvg(1);
> mSimulations(a,b,c,2) =vAvg(2);
> mSimulations(a,b,c,3) = vSTD(1);
> mSimulations(a,b,c,4) = vSTD(2);

which is not exactly the same jeff wants.....



"Michael Robbins" <michaelNOrobbinsSPAMusenet(a)yahoo.com> wrote in message
news:eefc30f.5(a)webx.raydaftYaTP...
> You may neet do do this instead
>
> mSimulations(a,b,c,1:N.*2) = [vAvg(1:N).' vSTD(1:N).'];
>
> or
>
> mSimulations(a,b,c,1:N.*2) = [vAvg(1:N) vSTD(1:N)].';
>
> or
>
> mSimulations(a,b,c,1:N.*2) = [vAvg(1:N).' vSTD(1:N).'].';
>
> I'm not sure which one.
>
> BTW, N=2 for your example.


From: Guillermo on
what exactly did you use?
and which are your variable contents?

"jeff" <REMREMn(a)REM.net> wrote in message news:eefc30f.6(a)webx.raydaftYaTP...
> hi all, thanks for the responses. Im actually dont have matlab again
> till the afternoon tomorrow, but I had tried Guillermo's solution
> (actually something equivalent to it) and it didn't work but gave me
> some random error. I'll try the newer ones out tomorrow. Thanks.


 |  Next  |  Last
Pages: 1 2
Prev: Convert C/C++ to Matlab
Next: greyscale to RGB