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:
inner join with text

Subject: inner join with text

From: charles atlas

Date: 4 Aug, 2009 12:21:03

Message: 1 of 3

 have A and B written in this way
A =
1
1
2
2
2
4
4
4
4
5
5
7
7
7

B =
1 278 23 .01
2 312 18 .02
4 411 91 .01
5 796 47 .05
7 195 65 .08

I have a program that manipulates the data on the right of B and duplicates it according to the column on the left corresponding to A. In other words the data turns out like C (shown bleow.)

C =
1 278 23 .01
1 278 23 .01
2 312 18 .02
2 312 18 .02
2 312 18 .02
4 411 91 .01
4 411 91 .01
4 411 91 .01
4 411 91 .01
5 796 47 .05
5 796 47 .05
7 195 65 .08
7 195 65 .08
7 195 65 .08

The program looks like this:
[tf loc] = ismember(A,B(:,1));
C(tf,:) = B(loc(tf),:)

now, what I really want to do is this:
my other set of data has text in it like so:

D =
1 278 23 .01 X1
2 312 18 .02 X2
4 411 91 .01 X3
5 796 47 .05 X4
7 195 65 .08 X5

How do I make that program (or another one) work for this set of data with text in it. My ultimate goal is to then write that data into an excel file (probaby using xlswrite.)

thanks in advance for any help.
-Charles

Subject: inner join with text

From: us

Date: 4 Aug, 2009 12:30:20

Message: 2 of 3

"charles atlas"
> D =
> 1 278 23 .01 X1
> 2 312 18 .02 X2
> 4 411 91 .01 X3
> 5 796 47 .05 X4
> 7 195 65 .08 X5
>
> How do I make that program (or another one) work for this set of data with text in it. My ultimate goal is to then write that data into an excel file (probaby using xlswrite.)
>
> thanks in advance for any help.
> -Charles

one of the solutions is outlined below

     n=[ % <- your numerical data
          1 2 3
          4 5 6
          7 8 9
     ];
     s={ % <- your text data in a CELL...
          'a'
          'bb'
          'ccc'
     };
     r=[num2cell(n),s] % <- create a CELL of mixed content...
%{
% r = % <- use R as input for XLSWRITE...
          [1] [2] [3] 'a'
          [4] [5] [6] 'bb'
          [7] [8] [9] 'ccc'
%}

us

Subject: inner join with text

From: charles atlas

Date: 4 Aug, 2009 16:27:02

Message: 3 of 3

"charles atlas" <mufasa1234555@yahoo.com> wrote in message <h5993f$1ea$1@fred.mathworks.com>...
> have A and B written in this way
> A =
> 1
> 1
> 2
> 2
> 2
> 4
> 4
> 4
> 4
> 5
> 5
> 7
> 7
> 7
>
> B =
> 1 278 23 .01
> 2 312 18 .02
> 4 411 91 .01
> 5 796 47 .05
> 7 195 65 .08
>
> I have a program that manipulates the data on the right of B and duplicates it according to the column on the left corresponding to A. In other words the data turns out like C (shown bleow.)
>
> C =
> 1 278 23 .01
> 1 278 23 .01
> 2 312 18 .02
> 2 312 18 .02
> 2 312 18 .02
> 4 411 91 .01
> 4 411 91 .01
> 4 411 91 .01
> 4 411 91 .01
> 5 796 47 .05
> 5 796 47 .05
> 7 195 65 .08
> 7 195 65 .08
> 7 195 65 .08
>
> The program looks like this:
> [tf loc] = ismember(A,B(:,1));
> C(tf,:) = B(loc(tf),:)
>
> now, what I really want to do is this:
> my other set of data has text in it like so:
>
> D =
> 1 278 23 .01 X1
> 2 312 18 .02 X2
> 4 411 91 .01 X3
> 5 796 47 .05 X4
> 7 195 65 .08 X5
>
> How do I make that program (or another one) work for this set of data with text in it. My ultimate goal is to then write that data into an excel file (probaby using xlswrite.)
>
> thanks in advance for any help.
> -Charles

Thank you for the program. It works and now I know how to write the text information into matlab. All I need to do now is get the program to work or get another program that will do what is shown above to the matrix with the text data "D" to make something that looks like C only it has the text data duplicated as well.

Tags for 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