How to make the program more flexible
Show older comments
I want to make a frame that can follow the pattern.
ex, M = 4,N = 4, I would got a 4 by 4 "x" (matrix)
However, this Mg by Ng frame will surround the M by N matrix
But my program is not flexible enough and the problem is in the frame settings, but I don’t know how to modify...
M = 4; % "\" pattern and "/" pattern (column)
N = 4; %"\" pattern and "/" pattern (Row)
Mg = 1; % Frame size (column)
Ng = 1; % Frame size (Row)
a = [1 0.5];
b = [0.5 1];
for q = 1:1:M*Mg
hold on;
for w = 1:1:N*Ng
hold on;
plot(a+q,b+w,'r') % "\" pattern
end
end
hold on;
a1 = [1 0.5];
b1 = [1 0.5];
for q = 1:1:M*Mg
hold on;
for w = 1:1:N*Ng
hold on;
plot(a1+q,b1+w,'b') % "/" pattern
end
end
%---------Frame size--------------
for M = 0 : M: M*Mg
hold on;
x=[1.25 1.25 1.25+M 1.25+M 1.25];
for N = 0 : N: N*Ng
y=[1.25 1.25+N 1.25+N 1.25 1.25];
plot(x,y,'k','lineWidth',2)
end
end
Hope to present the following fig, M = 4; N = 4; Mg = 2; Ng = 2;

Accepted Answer
More Answers (0)
Categories
Find more on Sensor Models 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!