Info

This question is closed. Reopen it to edit or answer.

how do i write general code using variables for my following code?

1 view (last 30 days)
% rectangle assembly
clc
close all
clear all
figure()
%% patch: Create one or more filled polygons
p1 = patch([0 0 2 2 0], [0 5 5 0 0], [0.5 0 0.5]);
p2 = patch([2 2 4 4 2], [0 5 5 0 0], [0.5 0 0.5]);
rotate(p2, [0 0 1], 120, [2 5 0])
p3 = patch([-2 -2 0 0 -2], [0 5 5 0 0], [0.5 0 0.5]);
rotate(p3, [0 0 1], -120, [0 5 0])
axis([-10 10 -5 15])
axis equal
grid on
  1 Comment
Geoff Hayes
Geoff Hayes on 1 Jun 2020
kanuri - what should the general variables be? The inputs to the patch function and/or the rotate function? Once you have determined what those general variables (or inputs) should be, you will probably want to change your above code from a script to a function.

Answers (0)

This question is closed.

Community Treasure Hunt

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

Start Hunting!