답변 (4개)

Walter Roberson
Walter Roberson 2015년 5월 23일

0 개 추천

sin(1/2*x) between 0 and 4*Pi, fill_between() that and 0
sin(x) between Pi and 3*Pi, fill_between that and 0
Image Analyst
Image Analyst 2015년 5월 23일

0 개 추천

Looks like sine waves. You can generate that picture with patch(), fill(), or area(). Why do you need this? Is this homework? Why don't you at least give it a try using one or more of the functions I mentioned? Come back with code if you have trouble.

댓글 수: 1

Image Analyst
Image Analyst 2015년 5월 23일
Regarding your "Answer" below:
Come on. I'm sure you can figure out that it's just sin with half the period , defined between pi/2 and 3*pi/2. It's just basic trig. for reference, the formula is sin(2*pi*t / period).

댓글을 달려면 로그인하십시오.

ZabIh Zabihullah
ZabIh Zabihullah 2015년 5월 23일

0 개 추천

the first on will be define like this t=0:pi/20:2*pi; fill(t,sin(t),'m') and i dont know how to define the second one if u can please helpe me
Geoff Hayes
Geoff Hayes 2015년 5월 23일

0 개 추천

Zablh - you can use the area function to get the desired shapes. Try the following
% create the sine curve for the interval (0,2pi)
x=0:0.01:2*pi;
y=sin(x);
% create the figure
figure;
hold on;
% draw the first (magenta) area
area(x,y,'FaceColor','m');
% now draw the yellow area
area(x/2+pi/2,-0.5*y,'FaceColor','y');
And that should give you the shapes that you want. We use the hold on so that we can plot two graphics objects on the same figure (the magenta and yellow areas/shapes). We then plot the larger of the two first, and then the smaller shape by manipulating the x and y data from the sine curve.

댓글 수: 5

Geoff Hayes
Geoff Hayes 2015년 5월 23일
Zablh's answer moved here
if u help a bit more hayes i am new this mathlab program it doesn't work what u have written i need ur helps because i have exam tomorrow thanks brothers. tell a bit more what to write in edit to give me this shape.
Geoff Hayes
Geoff Hayes 2015년 5월 23일
Zablh - you are going to have to explain what you mean by it doesn't work. The above should be sufficient to get you started.
Walter Roberson
Walter Roberson 2015년 5월 23일
Zabln commented "i am typing what r u wrote but it says that theres is problem in first coloumn dear sir"
Walter Roberson
Walter Roberson 2015년 5월 23일
Zablh, then you are making a typing mistake. If you highlight Geoff's code with your mouse and use your operating system's copy function (you can find it in your browser's edit menu), you can then go to the MATLAB command prompt and paste it in; it will work fine.
ZabIh Zabihullah
ZabIh Zabihullah 2015년 5월 23일

thanks Mr.hayes so much it works thank u have good life

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

태그

질문:

2015년 5월 23일

댓글:

2015년 5월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by