2

In MATLAB, I need to create a loop to iterate through the entire string array and plot.

In other words, First Iteration: the loop steps to Montana with its value (23,45) and generates plot.

Second Iteration: continue the loop to Georgia with its value (54,75) and plot.

Third Iteration: continue the loop to Texas with its value (55,90) and plot. So, we have 3 different plots for each string.

Here is the array:

A = {'Montana','Georgia','Texas'};

with X values:

X = [23, 54, 55]

with Y values:

Y = [45, 75, 90]

Thanks,

Amanda

1 Answer 1

3
% input data
A = {'Montana','Georgia','Texas'};
X = [23, 54, 55];
Y = [45, 75, 90];

%  plot points
figure(1);
plot(X, Y, 'rx');

% adjust the limits for figure axis
axis([0 70 0 100]);

% label points
text(X,Y, A, 'VerticalAlignment','bottom', ...
    'HorizontalAlignment','right');

The output figure Output

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.