Equations or code that can generate shapes
조회 수: 2 (최근 30일)
이전 댓글 표시
I have x and y coordinates of a n*2n grid fixed grid. I have generated circular shape (circle.JPG) with
sqrt((x-cx).^2 +(y-cy).^2)-r, where (cx, cy) are the centre and r is the radius of the circle
I have generated elliptical shape (ellipse.JPG) with
((x-cx)/a).^2 +((y-cy)/b).^2)-1, where (cx, cy) are the centre and a is the horizontal radius and b is the vertical radius of the ellipse
I need a code that can generate each of the following shapes in the picture (Picture_1.jpg).
Thank you so much.
댓글 수: 6
답변 (1개)
Image Analyst
2018년 10월 13일
Try this:
period = 10;
amplitude = 4;
offset = 6;
x = linspace(0, 40, 700);
y = amplitude * cos(2 * pi * x / period) + offset;
plot(x, y, 'b-', 'LineWidth', 2);
grid on;
ylim([0, amplitude + offset]);
For the triangle wave, use sawtooth() or repmat(). I'm sure you can figure it out because you're a smart engineer.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Elementary Polygons에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!