Enrgie.Dev
Enrgie.Dev

Reputation: 7

how to show a grid with loops ( Do or For )

i want to show this grid with loop ( Do or For ) and how to specify Lines color ? My code Is :

figure(1)
[X,Y] = meshgrid(-1:0.1:1, -1:0.1:1)
plot(X,Y,'k-')
hold on
plot(Y,X,'k-');

how can i do that ?

Upvotes: 0

Views: 41

Answers (1)

m7913d
m7913d

Reputation: 11064

You can try something like this.

[X,Y] = meshgrid(-1:0.1:1, -1:0.1:1);
deltaColor = 1/size(X, 2);
for i=1:size(X, 2)
    plot(X(:, i),Y(:, i), 'Color', [deltaColor*i 0 0])
    hold on
    plot(Y(:, i),X(:, i), 'Color', [0 deltaColor*i 0])
end

It may be not exactly what you are looking for, but your question is not that clear. I hope you will be able to apply it to your case.

enter image description here

Upvotes: 1

Related Questions