Thread Subject: Problems making a combined array with Char and Doubles

Subject: Problems making a combined array with Char and Doubles

From: Laurence 12a440

Date: 23 May, 2009 02:14:02

Message: 1 of 2

Hi
...snip
 fseek(fid, StartofField, 'bof');
    File_code=fread(fid, 1,'uint8');
    File_codes(count,1)=File_code;
    Filler = fread(fid, 7);
    Co_code = fread(fid, 14,'char');
    Co_code = char(Co_code)';
    Co_codes(count,2) = Co_code;

    count=count+1
...snip

File_codes is coming out as a double (for example 123 1)
Co_codes as a char (for example BHP ANZ )

I need to make a final array that looks like
123 BHP
1 ANZ

but I just can't get the two together, I know it will be something simple so can someone please help

Thanks

Subject: Problems making a combined array with Char and Doubles

From: Sadik

Date: 23 May, 2009 23:23:20

Message: 2 of 2

Because the array elements are not of the same size, it would be good to use a cell array.

I don't know your outputs exactly, therefore I will give a close approximation here:

numberOfCodes = length(File_codes);
cellArray = cell(numberOfCodes,1);

for k = 1:numberOfCodes
    cellArray{k} = [num2str(File_codes(k)) ' ' Co_codes(k)];
end

Something like this should work. [You will clearly need to modify the code according to your variables.]




"Laurence 12a440" <matt1234au@yahoo.com> wrote in message <gv7m59$i3h$1@fred.mathworks.com>...
> Hi
> ...snip
> fseek(fid, StartofField, 'bof');
> File_code=fread(fid, 1,'uint8');
> File_codes(count,1)=File_code;
> Filler = fread(fid, 7);
> Co_code = fread(fid, 14,'char');
> Co_code = char(Co_code)';
> Co_codes(count,2) = Co_code;
>
> count=count+1
> ...snip
>
> File_codes is coming out as a double (for example 123 1)
> Co_codes as a char (for example BHP ANZ )
>
> I need to make a final array that looks like
> 123 BHP
> 1 ANZ
>
> but I just can't get the two together, I know it will be something simple so can someone please help
>
> Thanks

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com