Reputation: 7
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
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.
Upvotes: 1