Vote count:
0
I have two vectors: `
R = [-1 -1 1 1];
T = [2.0741 2.1521 2.9529 2];
And I'm trying to make a barchart. The bars has different colors depending on the value in R. The y-axis is the value in T and X-axis should be the index number from R ie. numbers from 1 to length(R) - But this is my problem, I' can't find a way to do so.
this is my code:
figure;
for i=1:length(T)
h = bar(i, T(i));
if i == 1, hold on, end
if R(i) == -1
col = 'r';
else
col = 'g';
end
set(h, 'FaceColor', col)
end
asked 1 min ago
Aucun commentaire:
Enregistrer un commentaire