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:
Matrix lookup in symbolic function

Subject: Matrix lookup in symbolic function

From: Sjoerd

Date: 6 Oct, 2013 14:03:05

Message: 1 of 3

Hai - I want to do a matrix lookup (without symbolic contents) in a symbolix function;

In example;
>> A = [ 1 2 3 4 5 ]
>> s = symsum(A(j),j,1,length(A))

In get the following error;
Subscript indices must either be real positive integers or logicals.

Making A symbolic does not help. Making the contents of A symbolic (A = sym(A)) does also not help. Anyone had some idea's or suggestions?

Subject: Matrix lookup in symbolic function

From: Steven Lord

Date: 7 Oct, 2013 14:10:22

Message: 2 of 3


"Sjoerd " <sjjhuisman@hotmail.com> wrote in message
news:l2rqip$1qg$1@newscl01ah.mathworks.com...
> Hai - I want to do a matrix lookup (without symbolic contents) in a
> symbolix function;
>
> In example;
>>> A = [ 1 2 3 4 5 ]
>>> s = symsum(A(j),j,1,length(A))
>
> In get the following error;
> Subscript indices must either be real positive integers or logicals.
>
> Making A symbolic does not help. Making the contents of A symbolic (A =
> sym(A)) does also not help. Anyone had some idea's or suggestions?

Yes -- use SUM instead of SYMSUM.

s = sum(A);

You can't, in general, index into an array using a symbolic variable. You
can only do so if that symbolic variable happens to contain a numeric value:

three = sym(3);
A(three)

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

Subject: Matrix lookup in symbolic function

From: Sjoerd

Date: 10 Oct, 2013 15:14:06

Message: 3 of 3

Thanks for the info!

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