Q:

Write a script that will first initialize a string variable that will store x and y coordinates of a point in the form ‘x 3.1 y 6.4’. Then, use string manipulating functions to extract the coordinates and plot them

0

Write a script that will first initialize a string variable that will store x and y coordinates of a point in the form ‘x 3.1 y 6.4’. Then, use string manipulating functions to extract the coordinates and plot them.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Ch7Ex33.m

% create a string variable of the form 'x 3.1 y 6.4'

% extract the x and y coordinates and plot

str = 'x 2.3 y 4.5';

[letter, rest] = strtok(str);

[x, rest] = strtok(rest);

[letter, rest] = strtok(rest);

y = rest(2:end);

x = str2num(x);

y = str2num(y);

plot(x,y,'go')

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now