Thread Subject: Text and numbers/data in same matrix

Subject: Text and numbers/data in same matrix

From: Markus Due Jakobsen

Date: 16 May, 2008 16:42:02

Message: 1 of 5

Hi

How is it possible to make a matrix which includes
numbers/data and text?

Example:
I want X={'Moment'; 'Work'; 'Angle'} to be in column1,
Y=[222.115; 210.004; 78.112] to be in column2 and Z=
[211.114; 205.089; 76.112] to be in column3, so V=[X Y Z].

V=
Moment 222.115 211.114
Work 210.004 205.089
Angle 78.112 76.112

I want it to be possible calculate within the two data
vectors..

In other words I want it to be possible to save the matrix
to a file which have a header (ex. Moment, Work, Angle) to
each row of the Matrix or file.

Any suggestions?

Markus








Subject: Text and numbers/data in same matrix

From: Nicolás

Date: 16 May, 2008 16:54:02

Message: 2 of 5

Hi Markus. Have you thought in structure arrays? Search the
struct command, it may help.

Best,

Nicolas

Subject: Text and numbers/data in same matrix

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 16 May, 2008 17:08:38

Message: 3 of 5

In article <g0kdgq$48$1@fred.mathworks.com>,
Markus Due Jakobsen <markusdue@gmail.com> wrote:
>Hi
>
>How is it possible to make a matrix which includes
>numbers/data and text?
>
>Example:
>I want X={'Moment'; 'Work'; 'Angle'} to be in column1,
>Y=[222.115; 210.004; 78.112] to be in column2 and Z=
>[211.114; 205.089; 76.112] to be in column3, so V=[X Y Z].

That is not possible in Matlab.

>In other words I want it to be possible to save the matrix
>to a file which have a header (ex. Moment, Work, Angle) to
>each row of the Matrix or file.

That's a different question: there are a number of different
routines that allow you to write data to a file, several of which
allow you to write out data of different classes on the same line.
--
  "The quirks and arbitrariness we observe force us to the
  conclusion that ours is not the only universe." -- Walter Kistler

Subject: Text and numbers/data in same matrix

From: someone

Date: 16 May, 2008 20:54:01

Message: 4 of 5

"Markus Due Jakobsen" <markusdue@gmail.com> wrote in
message <g0kdgq$48$1@fred.mathworks.com>...
> Hi
>
> How is it possible to make a matrix which includes
> numbers/data and text?
>
> Example:
> I want X={'Moment'; 'Work'; 'Angle'} to be in column1,
> Y=[222.115; 210.004; 78.112] to be in column2 and Z=
> [211.114; 205.089; 76.112] to be in column3, so V=[X Y
Z].
>
> V=
> Moment 222.115 211.114
> Work 210.004 205.089
> Angle 78.112 76.112
>
> I want it to be possible calculate within the two data
> vectors..
>
> In other words I want it to be possible to save the
matrix
> to a file which have a header (ex. Moment, Work, Angle)
to
> each row of the Matrix or file.
>
> Any suggestions?
>
> Markus
>

% You could make Y & Z cell vectors also ...

X={'Moment'; 'Work'; 'Angle'}
Y={222.115; 210.004; 78.112}
Z = {211.114; 205.089; 76.112}

V = {X Y Z}

% You may be able to save V to a file, but,
% working with the V cell array will be difficult.

% Using structures my be better to do the calculations.

Subject: Text and numbers/data in same matrix

From: Bob

Date: 22 May, 2008 17:01:13

Message: 5 of 5

Markus, if you have the Statistics Toolbox you might find the DATASET
object interesting.

X = {'Moment'; 'Work'; 'Angle'};
Y = [222.115; 210.004; 78.112];
Z = [211.114; 205.089; 76.112];
V = dataset(X,Y,Z)

V =
     X Y Z
     'Moment' 222.12 211.11
     'Work' 210 205.09
     'Angle' 78.112 76.112

V(1,:)
ans =
     X Y Z
     'Moment' 222.12 211.11

V(:,1)
ans =
     X
     'Moment'
     'Work'
     'Angle'

Cheers
Bob

Tags for this Thread

Everyone's Tags:

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.

Tag Activity for This Thread
Tag Applied By Date/Time
text and data in same matrix Markus Due Jakobsen 16 May, 2008 12:45:10
rssFeed for this Thread

Public Submission Policy

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 Disclaimer prior to use.

Contact us at files@mathworks.com