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
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:7| Question number:33.7
All Answers
total answers (1)
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