Help with plotting a function

I need to plot the function y = √(sin(x^2)) over the domain [2.75, 3] but when i try entering the code it does not work for me. It tells me "Not enough input arguments". I've tried almost everything to do this problem. Please help. Here is what I have:
x=[2.75, 3]
y=sqrt(sin*(x^2))
plot(x,y)
title = ('This is all the things')
xlabel=('This is the bottom')
ylabel=('This is the side')

1 件のコメント

Brianna Selles
Brianna Selles 2019 年 9 月 1 日
I used the code but now the table, x and y labels are not populating. Help?

回答 (1 件)

madhan ravi
madhan ravi 2019 年 9 月 1 日
編集済み: madhan ravi 2019 年 9 月 1 日

0 投票

x=linspace(2.75, 3,1000)
y=sqrt(sin(x.^2)) % have a look here
plot(x,y)
title('This is all the things')
xlabel('This is the bottom')
ylabel('This is the side')
doc linspace

8 件のコメント

Brianna Selles
Brianna Selles 2019 年 9 月 1 日
Why use linspace for this function? Also, the title, x, label, and y label are not populating on the graph
Walter Roberson
Walter Roberson 2019 年 9 月 1 日
Your initial code plotted only at x = 2.75 exactly and x = 3 exactly. Using linspace() line madhan shows makes it plot at a number of locations between those two values as well.
clear title xlabel ylabel %get rid of the values that were accidentally assigned
title('This is all the things')
xlabel('This is the bottom')
ylabel('This is the side')
Brianna Selles
Brianna Selles 2019 年 9 月 1 日
Ah, something really bad happened to my program. I don't know what happened. When I put this it does not display the graph at all now:
x=linspace(2.75, 3)
y=sqrt(sin(x.^2))
plot(x,y)
clear title xlabel ylabel
title('This is all the things')
xlabel('This is the bottom')
ylabel('This is the side')
doc linspace
Brianna Selles
Brianna Selles 2019 年 9 月 1 日
Plot the function z = y^4 - x^3 yover the square [-2,2]×[-2,2] that lies in the xy-plane.
[x, y] = meshgrid(-2*pi:0.25:5, -2*pi:0.25:5)
z= y^4 - x^3
surf(x, y, z)
This one just produced a bunch of numbers when I went to publish it. Is that right? Is there supposted to be so many numbers like this?
Walter Roberson
Walter Roberson 2019 年 9 月 1 日
Remove the
doc linspace
line. madhan was attempting to convey to you that you should read the documentation for linspace.
Walter Roberson
Walter Roberson 2019 年 9 月 1 日
編集済み: Walter Roberson 2019 年 9 月 1 日
You should put a semi-colon at the end of expressions. Also, I recommend you turn off edgecolor on surf plots:
[x, y] = meshgrid(-2*pi:0.25:5, -2*pi:0.25:5);
z= y^4 - x^3;
surf(x, y, z, 'edgecolor', 'none')
I think it unlikely that it will give you the output you are looking for. Have you ever examined the documentation about the mpower function, also known as ^ and compared it to the documentation for the power function, also known as .^ ?
madhan ravi
madhan ravi 2019 年 9 月 1 日
Thank you sir Walter :)
Brianna Selles
Brianna Selles 2019 年 9 月 1 日
Thanks guys!

この質問は閉じられています。

質問済み:

2019 年 9 月 1 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by