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:
Subscript indices must either be real positive integers or logicals.

Subject: Subscript indices must either be real positive integers or logicals.

From: rasika

Date: 24 Oct, 2011 08:38:30

Message: 1 of 7

function [ Int ] = Integrationoverzones( A,l,m,R,Is,t,Ccell)
%
for i=0:1:size(t)
Inte= Is*{((exp(-0.079.*(50-R)) + (6*10^-9).*Ccell(i).^-2.5 ))./( exp((3.5*10^-10).*Ccell(i).*(50-R))+ (6*10^-9).*Ccell(i).^-2.5)};

Int = int((Inte*2*pi*R /A ), l,m);




end
end
%ccell is supposed to be a vector input and R is a variable
Please reply soon.
I am getting this error
??? Subscript indices must either be real positive integers or logicals. at the formula.of inte.

Subject: Subscript indices must either be real positive integers or logicals.

From: Steven_Lord

Date: 24 Oct, 2011 18:54:23

Message: 2 of 7



"rasika " <n.rasika@gmail.com> wrote in message
news:j83865$7co$1@newscl01ah.mathworks.com...
> function [ Int ] = Integrationoverzones( A,l,m,R,Is,t,Ccell)
> %
> for i=0:1:size(t)
> Inte= Is*{((exp(-0.079.*(50-R)) + (6*10^-9).*Ccell(i).^-2.5 ))./(
> exp((3.5*10^-10).*Ccell(i).*(50-R))+ (6*10^-9).*Ccell(i).^-2.5)};

MATLAB uses one-based indexing, not zero-based indexing like C or C++. There
is no such thing as an element 0 of the Ccell variable.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Subscript indices must either be real positive integers or logicals.

From: rasika

Date: 25 Oct, 2011 03:06:13

Message: 3 of 7

Hello Steven,
yes, i changed it from 1:size(t)
it ran,but it is giving me only a single output, where as I was expecting a vector, since Ccell is a vector,
Can you please let me know about that?
 Thank you for your earlier suggestion ..:)


"Steven_Lord" <slord@mathworks.com> wrote in message <j84c91$9ev$1@newscl01ah.mathworks.com>...
>
>
> "rasika " <n.rasika@gmail.com> wrote in message
> news:j83865$7co$1@newscl01ah.mathworks.com...
> > function [ Int ] = Integrationoverzones( A,l,m,R,Is,t,Ccell)
> > %
> > for i=0:1:size(t)
> > Inte= Is*{((exp(-0.079.*(50-R)) + (6*10^-9).*Ccell(i).^-2.5 ))./(
> > exp((3.5*10^-10).*Ccell(i).*(50-R))+ (6*10^-9).*Ccell(i).^-2.5)};
>
> MATLAB uses one-based indexing, not zero-based indexing like C or C++. There
> is no such thing as an element 0 of the Ccell variable.
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

Subject: Subscript indices must either be real positive integers or logicals.

From: Matt J

Date: 25 Oct, 2011 13:03:15

Message: 4 of 7

"rasika " <n.rasika@gmail.com> wrote in message <j83865$7co$1@newscl01ah.mathworks.com>...
> function [ Int ] = Integrationoverzones( A,l,m,R,Is,t,Ccell)
> %
> for i=0:1:size(t)
> Inte= Is*{((exp(-0.079.*(50-R)) + (6*10^-9).*Ccell(i).^-2.5 ))./( exp((3.5*10^-10).*Ccell(i).*(50-R))+ (6*10^-9).*Ccell(i).^-2.5)};
=======

If Ccell is a cell array containing a vector, then that vector is to be accessed
as Ccell{i}.

Also, I don't understand why you are not getting an error from this

Inte=Ix*{...}

since multiplication with cell arrays is undefined:

Subject: Subscript indices must either be real positive integers or logicals.

From: rasika

Date: 25 Oct, 2011 13:41:13

Message: 5 of 7

yes, I removed that when I ran it from 1:size(t)
now I am getting some unintelligible o/ps like this
(10396344664475805277532160*pi)/4958531319053791
and also with some changes, an error saying that explicit integral cannot be evaluated..

Why does the int syntax not find the final numeric value and leaves answers in Numerator/denominator form?
and why it is unable to evluate the function? do I have to use symbolic math toolbox, I did that too. but similar error it gave me..
"Matt J" wrote in message <j86c2j$kua$1@newscl01ah.mathworks.com>...
> "rasika " <n.rasika@gmail.com> wrote in message <j83865$7co$1@newscl01ah.mathworks.com>...
> > function [ Int ] = Integrationoverzones( A,l,m,R,Is,t,Ccell)
> > %
> > for i=0:1:size(t)
> > Inte= Is*{((exp(-0.079.*(50-R)) + (6*10^-9).*Ccell(i).^-2.5 ))./( exp((3.5*10^-10).*Ccell(i).*(50-R))+ (6*10^-9).*Ccell(i).^-2.5)};
> =======
>
> If Ccell is a cell array containing a vector, then that vector is to be accessed
> as Ccell{i}.
>
> Also, I don't understand why you are not getting an error from this
>
> Inte=Ix*{...}
>
> since multiplication with cell arrays is undefined:

Subject: Subscript indices must either be real positive integers or logicals.

From: Matt J

Date: 25 Oct, 2011 13:56:29

Message: 6 of 7

"rasika " <n.rasika@gmail.com> wrote in message <j86e9p$4a$1@newscl01ah.mathworks.com>...
>
> Why does the int syntax not find the final numeric value and leaves answers in Numerator/denominator form?
============

Because it is doing symbolic math ?

> and why it is unable to evluate the function?
===============

We can't see your modified code, so we cannot know.

Subject: Subscript indices must either be real positive integers or logicals.

From: rasika

Date: 25 Oct, 2011 15:38:31

Message: 7 of 7

My new code goes like this
function [Int] = Calint1(Is,l,m,A)% values of a,b,c as of now taken for 260

  
t= [ 0, 12.2,18.7,23.7,35.7,41.7,47.7,60.5,65.7,71.7,84.2,90.4,95.7,107.7,113.7,119.7,132.2,137.7,143.7,156.2,161.7,167.7,180.2,184.7]';
for i=0:1:size(t)


Ccell= [0.0978, 0.1902,0.2685,0.3478,0.6250,0.8175,1.0466,1.6259,1.8737,2.1489,2.6324,2.8140,2.9387,3.1341,3.1968,3.2430,3.3026,3.3184,3.3310,3.3468,3.3510,3.3542,3.3583,3.3592]';
syms R;
Intensity = Is*((exp(-0.079*(50-R)) + (6*10^-9).*Ccell.^-2.5 ))./( exp((3.5*10^-10).*Ccell.*(50-R))+ (6*10^-9).*Ccell.^-2.5);
Int =int((Intensity*2*pi*R /A ), l,m);
 
end

workspace and o/p
[Int] = Calint1(260,0,37,Ariser) %Ariser is calculated in workspace any random value %would do
Warning: Explicit integral could not be found.

 
Int =
 
      int((2305843009213693952*pi*R*(260*exp((79*R)/1000 - 79/20) + 153927836943765885/295147905179352825856))/(4958531319053791*(exp(132420898577308025/77371252455336267181195264 - (5296835943092321*R)/154742504910672534362390528) + 2368120568365629/1180591620717411303424)), R = 0..37)
        such 20+ values
Please help me.. at this point I have just input Ccell as vector for simplification benefit, otherwise in my actual code its calculating as ccell=f(a,b,c,t)

Tags for 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