From: Steven Lord on

"Yukiko Shimizu" <yk.mizu(a)gmail.com> wrote in message
news:hvg97g$gp$1(a)fred.mathworks.com...
> "James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message
> <hvg8n7$rmd$1(a)fred.mathworks.com>...
>> "Yukiko Shimizu" <yk.mizu(a)gmail.com> wrote in message
>> <hvg6qk$t4e$1(a)fred.mathworks.com>...
>> > Hi everyone. Right now my program acts upon one input. I want to make
>> > it general though by using the randn option so that I can input one
>> > matrix or a random number of made up matrices. How can I make it so
>> > that my code acts on all of the matrices say for randn(:.:.4)?
>>
>> I don't understand the question. Please post a more detailed question,
>> preferably with examples.
>>
>> James Tursa
>
> So my original input is a matrix A=[2;3;4]. But Now I want to make it so
> that my program will take an input randn(3,1,3) for example. I want to get
> three outputs since the input now is three random matices. But when I run
> it, my program accepts the three matrice input but only gives me one
> matrix. I'm guessing my program only acts on the first of the generated
> random matrices.

So you want to call your function f with B = randn(3, 1, 3) and have f
operate first on B(:, :, 1) then on B(:, :, 2) and finally on B(:, :, 3)?

B = randn(3, 1, 3);
% I'm going to assume your function returns a scalar (1-by-1) value
results = zeros(1, size(B, 3));
for whichpage = 1:size(B, 3);
Atemp = B(:, :, whichpage);
results(whichpage) = callMyFunctionOn(Atemp);
end

You can, of course, eliminate the temporary named variable if you wish.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com


From: Oleg Komarov on
"Yukiko Shimizu" <yk.mizu(a)gmail.com> wrote in message <hvg97g$gp$1(a)fred.mathworks.com>...
> "James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message <hvg8n7$rmd$1(a)fred.mathworks.com>...
> > "Yukiko Shimizu" <yk.mizu(a)gmail.com> wrote in message <hvg6qk$t4e$1(a)fred.mathworks.com>...
> > > Hi everyone.
> > >
> > > Right now my program acts upon one input. I want to make it general though by using the randn option so that I can input one matrix or a random number of made up matrices. How can I make it so that my code acts on all of the matrices say for randn(:.:.4)?
> >
> > I don't understand the question. Please post a more detailed question, preferably with examples.
> >
> > James Tursa
>
> So my original input is a matrix A=[2;3;4]. But Now I want to make it so that my program will take an input randn(3,1,3) for example. I want to get three outputs since the input now is three random matices.

Here you're wrong: randn(3,1,3) "is" one three dimensional matrix.

Oleg