For Programmers: Free Programming Magazines  


Home > Archive > Matlab > January 2008 > using "eval" with strings from a cell array









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author using "eval" with strings from a cell array
Walter Roberson

2008-01-31, 8:28 pm

In article <fntspc$v38$1@news.albasani.net>,
=?UTF-8?B?TWljaGFlbCBSwppvZXNjaA==?= <mr_78-25@web.de> wrote:

>eval('string' cell_array(1))


>returns these error:


>Undefined function or method 'eval' for input arguments of type 'cell'


>Any ideas how to change a single cell to a ordinary string?


cell_array{1} instead of cell_array(1)


>But I'm not able to access these filenames with the eval function to
>alter them before saving again.


It seems unlikely to me that you need to use eval to do what
you want to do. For example, if you wanted to change the extension
on each filename to 'xls', you could use

for K=1:length(cell_array)
cell_array{K} = [cell_array{K}(1:end-3) 'xls'];
end
--
This is a Usenet signature block. Please do not quote it when replying
to one of my postings.
http://en.wikipedia.org/wiki/Signature_block
Michael Ršoesch

2008-01-31, 8:28 pm

Hello,

with uigetfile and the MultiSelect option I read several filenames into
a cell array.

But I'm not able to access these filenames with the eval function to
alter them before saving again.

These code:

eval('string' cell_array(1))

returns these error:

Undefined function or method 'eval' for input arguments of type 'cell'

Any ideas how to change a single cell to a ordinary string?


Thanks, Michael
Michael Ršoesch

2008-01-31, 11:18 pm

Walter Roberson schrieb:

> cell_array{1} instead of cell_array(1)


I thought, I had first tried this unsuccessfully, but (now) it works.

And you are right, for the example provided, I should not need eval.

But actually I intended to write a new file based on the name of the
original file with dlmwrite and therefor I needed this cell array
content as ordinary string.

Now I solved this with simple concatenating (and with {} instead of () ):

output_file_name=['output_' file_name{1}];

dlmwrite([output_path_name output_file_name], data, '\t');


Thanks for your help,
Michael
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com