how can i define this shape
5 views (last 30 days)
Show older comments
0 Comments
Answers (4)
Image Analyst
on 23 May 2015
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 Comment
Image Analyst
on 23 May 2015
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).
Geoff Hayes
on 23 May 2015
% 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 Comments
Walter Roberson
on 23 May 2015
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.
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!