MATLAB: Can I assign a value from textscan to anything other than a cell array

cell arraysMATLABtextscan

I want to assign the value from a textscan directly to an simple variable, can I do this? Example:
str = '223 87 87';
[Nx, Ny, Nz] = textscan(str, '%f %f %f');
I know this doesn't work, because textscan returns a cell array, rather than a list of numbers. So I could do something like
Narray = textscan(str, '%f %f %f');
Nx = Narray{1}; Ny = Narray{2}; Nz = Narray{3}; clear Narray;
But then it takes two lines and an extra cell array that I never wanted to exist in the first place…it seems inefficient and less readable. Is there a way that I can have the output from textscan assigned directly to the variables I want, or is an intermediate cell array always necessary? Thanks!

Best Answer

The insistence of textscan to return only cell array is annoying often, indeed. Only way around what you're doing I'm aware of is to not generate the three separate variables but use an array instead--then you can at least eliminate the explicit temporary
>> Nxyz=cell2mat(textscan(str,'%f'))
Nxy =
223
87
87
>>
If you're not reading a string but a file, I often still revert to textread for the same reason; in that case you can have the multiple outputs as well.
ADDENDUM
It seems one should be able to deal the outputs, but I couldn't manage to force textscan to generate a comma-separated list without the explicit temporary so ended up with the array propagated over the three variables instead of the three elements distributed. But, it might be some better than the explicit evaluation...
>> C=textscan(str,'%f%f%f')
C =
[223] [87] [87]
>> [Nx Ny Nz]=deal(C{1,:})
Nx =
223
Ny =
87
Nz =
87
>>
The difficulty here is that one must use a counted format string to force the creation of the cell array of N elements instead of the single cell of an N-sized array. And, since there's no syntax for array or cell array access after a function, the explicit temporary must be available for the dereferencing expression since
>> [Nx Ny Nz]=deal(textscan(str,'%f%f%f'))
Nx =
[223] [87] [87]
Ny =
[223] [87] [87]
Nz =
[223] [87] [87]
>>
as previously noted which is same result as is
>> [Nx Ny Nz]=deal(C)
The latter seems an incorrect choice for the implementation of deal to me but is as documented.
ADDENDUM
"The difficulty here is that one must use a counted format string ..."
Actually, it just dawned on me in thinking over Walter's most-excellent addition of dealcell that the facility of textscan to automagically parse the input record and return the proper number of elements if the formatSpec field is the empty string comes into play here...I think the best end solution is then
[Nx Ny Nz]=dealcell(textscan(str,''));