Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Need help for "Indexing cannot yield multiple results"

Subject: Need help for "Indexing cannot yield multiple results"

From: Nicole

Date: 10 Feb, 2010 19:13:02

Message: 1 of 3

Hi all,

I'm practicing to create exponential random numbers. The following is my code. I can only run it once. When I tried to run the second time, it appeared the error message, "Indexing cannot yield multiple results". I can run my code again if I use clear all. How can I solve it? Thank you!

function [exprand,average,std_dev]=exprand(m,n,h,mu)
exprand=zeros(m,n,h);
exprand=-mu*log(1-rand(m,n,h));
average=sum(sum(exprand))/(m*n);
std_dev=sqrt(sum(sum((exprand-average).^2))/(m*n));

Subject: Need help for "Indexing cannot yield multiple results"

From: Loren Shure

Date: 10 Feb, 2010 19:21:19

Message: 2 of 3

In article <hkv0fu$nrk$1@fred.mathworks.com>, nicolechang1115
@yahoo.com.tw says...
> Hi all,
>
> I'm practicing to create exponential random numbers. The following is my code. I can only run it once. When I tried to run the second time, it appeared the error message, "Indexing cannot yield multiple results". I can run my code again if I use clear all. How can I solve it? Thank you!
>
> function [exprand,average,std_dev]=exprand(m,n,h,mu)
> exprand=zeros(m,n,h);
> exprand=-mu*log(1-rand(m,n,h));
> average=sum(sum(exprand))/(m*n);
> std_dev=sqrt(sum(sum((exprand-average).^2))/(m*n));
>

You have an output variable named the same as the function. That's a
poor idea.

--
Loren
http://blogs.mathworks.com/loren
http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: Need help for "Indexing cannot yield multiple results"

From: Nicole

Date: 10 Feb, 2010 23:24:02

Message: 3 of 3

Loren Shure <loren.shure@mathworks.com> wrote in message
> You have an output variable named the same as the function. That's a
> poor idea.

Thank you! Solved.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us