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: char to string - comp.soft-sys.matlabI 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. convert string to ascii - comp.soft-sys.matlabconverting a character string into a variable name - comp.lang ... convert string to ascii - comp.soft-sys.matlab Hello Can anybody tells how to convert a string in ... or ... Add the character ' to a string - comp.soft-sys.matlabHi! How can i add the character ' to a string? For example if I want to build the string ABC'DEF. How can I do it? Thanks, Sónia ... varchar2 to hex/octal ... convert string - comp.databases.oracle ...is there way to 'dump' a string (varchar2) to the screen in hex? "this is a string" would print something like "33 44 23 64 345 43 34 ..." (I ju... Convert all cell array to string - comp.soft-sys.matlabchar to string - comp.soft-sys.matlab Convert char to double - comp.soft-sys.matlab Convert all cell array to string - comp.soft-sys.matlab Convert to character array ... Converting UTF-16 character strings to ISO8859-1 - comp.os.vms ...Are there any native OpenVMS character string conversion functions that will convert from UTF-16 to ISO8859-1? Thanks in advance for any wisdom, ... PL1 CHAR limit is 32767, but I need more long string type - comp ...Hi All PL1 type CHAR's largest length is 32767, but I need define a string type which largest length is 4M bytes to store MQ messages. I trie... Iterating over a String - comp.lang.java.helpIt has bugged me that the for:each syntax would not let me write code of the form: String categories = "amq"; .... for ( char category: categori... converting a character string into a variable name - comp.lang ...I have a FORTRAN question. The problems is: I want to write several variables, arrays and scalars, out to a file. I want to store the names of ... extracting from Any to typedef String - comp.soft-sys.ace ...char to string - comp.soft-sys.matlab extracting from Any to typedef String - comp.soft-sys.ace ... I tried assigning extract const char* to String_var type and then print ... C# Convert Char Array to String - Dot Net PerlsThis C# program converts a char array to a string. It uses the string constructor. char array to string? - C / C++char array to string?. C / C++ Forums on Bytes. ... Hi, I created an array of characters and want to convert that array to a 7/20/2012 7:27:15 PM
|