char to string

  • Follow


I have a file name, which is a character array, and i want to place this name into  a matrix. To do this, i've tried to convert the char array into a string. However, i have not found any command that can do this easily.

So, is there an easy command to convert a char array into a string, or to convert the elements of a char array into strings?
Or maybe another solution to import the character array into a matrix?

gr,

Stefan
0
Reply Stefan 5/4/2010 10:30:23 AM

Stefan Heinen wrote:
> I have a file name, which is a character array, and i want to place this 
> name into  a matrix. To do this, i've tried to convert the char array 
> into a string. However, i have not found any command that can do this 
> easily.
> 
> So, is there an easy command to convert a char array into a string, or 
> to convert the elements of a char array into strings?

In Matlab, character arrays and character strings are exactly the same 
thing.

> Or maybe another solution to import the character array into a matrix?

Based upon your description here and upon your later posting about 
dlmwrite, it appears that you are trying to set an array position to be 
a character string as if the string were a single unit. That is, 
however, not possible in a numeric array. The closest you can get to 
that is the cell arrays that someone else mentioned.
0
Reply Walter 5/4/2010 3:17:16 PM


No these are 2 different problems. This one, is a problem from my buddy. He has import de directory file with dir. Something like:

sigfiles = dir([workdir '\*t?.sig']) ;

The next thing he likes is to display the name and byte in the command window. I got them both appart but cant put them to getter. This with a loop:

sigfiles(i).name and sigfiles(i).bytes

I got two lists.. but can't add them to getter to display them.. 
Anyone knows how?

Best regards,

Stefan
0
Reply Stefan 5/4/2010 3:41:19 PM

Stefan Heinen wrote:
> He has import de directory file with dir. Something like:
> 
> sigfiles = dir([workdir '\*t?.sig']) ;
> 
> The next thing he likes is to display the name and byte in the command 
> window. I got them both appart but cant put them to getter. This with a 
> loop:
> 
> sigfiles(i).name and sigfiles(i).bytes
> 
> I got two lists.. but can't add them to getter to display them.. Anyone 
> knows how?

printf('%s %d\n', sigfiles(i).name,  sigfiles(i).bytes);
0
Reply Walter 5/4/2010 4:21:54 PM

"Stefan  Heinen" <s.g.h.heinen@live.com> wrote in message <hrosvv$aqh$1@fred.mathworks.com>...
> I have a file name, which is a character array, and i want to place this name into  a matrix. To do this, i've tried to convert the char array into a string. However, i have not found any command that can do this easily.
> 
> So, is there an easy command to convert a char array into a string, or to convert the elements of a char array into strings?
> Or maybe another solution to import the character array into a matrix?
> 
> gr,
> 
> Stefan

one of the solutions
- requires you to download a FEX submission, which comes with many options...

http://www.mathworks.com/matlabcentral/fileexchange/23840

% now
     d=dir('*.m');
     cprintf([{d.name}.',num2cell([d.bytes].')]);
%{
% note: nice formatting seen only in the original view...
   cdi.m    10240
 cmake.m       39
    do.m     1043
 fconv.m      219
getall.m      679
    gp.m    13950
    rp.m     2956
    wo.m       42
 woloc.m      268
%}

us
0
Reply us 5/4/2010 5:51:04 PM

4 Replies
520 Views

(page loaded in 0.142 seconds)

Similiar Articles:













7/20/2012 7:27:15 PM


Reply: