Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MATLAB Strings are used for which of the following(check all that apply): A.File

ID: 3677503 • Letter: M

Question

MATLAB Strings are used for which of the following(check all that apply): A.Filenames B.Calculating C.Line style parameters D.Printing to the command line or a file E.Titles,legends, axes MATLAB Strings are used for which of the following(check all that apply): A.Filenames B.Calculating C.Line style parameters D.Printing to the command line or a file E.Titles,legends, axes MATLAB Strings are used for which of the following(check all that apply): A.Filenames B.Calculating C.Line style parameters D.Printing to the command line or a file E.Titles,legends, axes

Explanation / Answer

In matlab all variables as arrays, and strings are considered as character arrays.

Using strings in matlab we have perform the following operations

1)converting string in to file name

function input_data str1 = input('first part of filename:, 's'); str2 = input('second part of filename:, 's');

target_file = strcat(str1, str2, '_test_data');

2)calculating strings in matlab using two functions.Those are

i)x = strmatch(str, strarray)

It compare through the rows of the character array or cell array of strings strarray to find strings that begin with the text contained in str, and returns the matching row indices. If strmatch does not find str in strarray, x is an empty matrix ([]).

Example:

The statement

x = strmatch('max', char('max', 'minimax', 'maximum'))

returns x = [1; 3] since rows 1 and 3 begin with 'max'. The statement

ii)x = strmatch(str, strarray, 'exact')

It compares str with each row of strarray, looking for an exact match of the entire strings.

Example:

x = strmatch('max', char('max', 'minimax', 'maximum'),'exact')

returns x = 1, since only row 1 matches 'max' exactly

3)In matlab ploting the functions using line style parameters. And the ploting function accept the line style parameters in string format.

Eg:

figure

t = 0:pi/20:2*pi;

plot(t,sin(t),'-.r*')

hold on

plot(t,sin(t-pi/2),'--mo')

plot(t,sin(t-pi),':bs')

hold off

4)Using string in mathlab we Print formatted data in to command line, Through printf statement

Eg::

Calling printf with one string argument.

printf('Hello World');

5)tiles are using strings for giving name for every loop in matrix.

EG:

tiles = {'r02cn1', 'r02gz2', 'r02hz1', 'r07dn1', 'r07dz1'};

    for v = 1:length(tiles)

    fileAHN2_05m = ['Geconverteerde data/ahn2/ahn2_05_ruw/' ...

                     char(tiles(v)), '/' char(tiles(v)), '.tif'];

    [AHN2, R_AHN2] = geotiffread(fileAHN2_05m);

    tiles{v} = AHN2;