MATLAB Easiest way to assign elements of a vector to individual variables [closed]?

Convert to cell array. PCell = num2cell(p); x,y,z = pCell{:}.

Well, looks like this is the best I can do. – rlbond May 23 '10 at 21:19.

You can use deal: x y z = deal( p(1), p(2), p(3) ).

1 Well, that's just as verbose as x = p(1); y = p(2), z = p(3) – rlbond May 23 '10 at 21:18.

Well, turns out there's no way to one-line this, so I wrote a function. Function varargout = deal_array(arr) s = numel(arr); n = nargout; if n > s error('Insufficient number of elements in array! '); elseif n == 0 return; end for I = 1:n varargout(i) = {arr(i)}; %#ok end end.

So let's say I have a vector p = 1 2 3. So that x = p(1), y = p(2), and z = p(3). Is there an easy way to do this?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions