"

11 How to make a matrix using string variables:

How to make a matrix using string variables:

1. First you must assign a variable, to do so type the following into the command window
b=string

1.  Next open a bracket using your keyboard and type what you wish into the command window remembering
to close the brackets when done (Note: ensure that what you are typing is between apostrophes for example
‘hello everyone’)

2. Next press enter on your keyboard and the new variable should appear in both the command window and
the workspace section.

3. Now to have a message appear in the same row do the same thing with an additional message for example
b=[string(‘hello everyone’) string( ‘hi everyone’)]. Once done press enter on your keyboard. (Note: to
avoid an error message you must ensure that everything is in squared brackets)

4. To create another row or column simply insert a semicolon where you wish for the new row or column to
begin for example; b=[string(‘hello everyone’) string( ‘hi everyone’); string(‘hi guys’) string(‘hi
everyone’)]

5. If you with to find a particular variable in a row or column simply type the variable then the row number
and the column number ex: to find hi everyone that is located in row 1 column 2 type b(1,2)

 

License

Tech Tangerine Guide - Matlab Copyright © by pranjalsaloni. All Rights Reserved.