Strange eval behaviour with cells

1 view (last 30 days)
GerdaHotlich
GerdaHotlich on 17 Apr 2014
Edited: GerdaHotlich on 17 Apr 2014
Hi there!
When trying to pass cell values to varargout, I noticed a strange behaviour of the eval function:
A = {1,2,3};
B1 = { A{1:3} }
B2 = { eval( 'A{1:3}' ) }
returns:
B1 =
[1] [2] [3]
B2 =
[1]
However,
eval( 'A{1:3}' )
returns
ans =
1
ans =
2
ans =
3
So I ask myself, where do the remaining cells get lost? In contrast,
A{1:3}
eval( 'A{1:3}' )
[B2, B3, B4] = A{1:3}
[B2, B3, B4] = eval( 'A{1:3}' )
generate equal outputs respectively.

Answers (0)

Categories

Find more on Programming Utilities in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!