Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

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

No tags are associated with this thread.

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.

Contact us