Question

Plotting 11) Plot the function y = sin(x) from x = 0 to 21. 12) Plot the functions y = x2 z = x2 + 2x + 1 from x = 0 to 2 on Please show the code necessary, and explanations on MATLAB.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

11) Plot function y=sin(x)

% define x

x=[0:0.1:2*pi];

% compute y
y=sin(x);

% open a figure window and plot x and y

figure

plot(x,y);
xlabel('elements in vector x from 0 to 2pi');
ylabel('elements in vector y=sinx');
title ('The sine function from 0 to 2pi');
grid on,axis equal

12) Plot function y=

% define x

x=[0:0.1:2];

% compute y
y=x.^2;

% open a figure window and plot x and y

figure

plot(x,y);
hold on

%compute z

z= x.^2 + 2*x +1;

plot(x,z);

legend({'y=x.^2','z= x.^2 + 2*x +1'},'Location','southwest')

hold off

grid on, axis equal

M-script to read message from command line using input function.

x = input(prompt) displays the text in prompt and waits for the user to input a value and press the Return key.

str = input(prompt,'s') returns the entered text, without evaluating the input as an expression.

using input function without 's'

x = input(prompt) displays the text in prompt and waits for the user to input a value and press the Return key.

It will display output with a syntax error.

Add a comment
Know the answer?
Add Answer to:
Please show the code necessary, and explanations on MATLAB. Plotting 11) Plot the function y =...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT