MATLAB: How to change the LineWidth according to several conditions

linewidth

I am applying a compass plot and I would like the line's width changes according to certain conditions depending on one variable numress. I would like that if 0<numress<10 the LineWidth in plot plot is 0.5, if 10<numress<50 the LineWidth is 2. And so on
I tried this but does not work:
h=compass(u,v,'r')
if (0<=numress) & (numress<=10)
h.LineWidth=0.5
end
if (10<numress) & (numress<=50)
h.LineWidth=2
end
if (50<numress) & (numress<=100)
h.LineWidth=4
end
.
.
.
if (500<numress) & (numress<=550)
h.LineWidth=22
end
get(h,'LineWidth')
I tried with: get, set but the lines width do not change in my compass plotting. Can you please help me with this problem? Thank you

Best Answer

Often you pass in the line width. So compute it in advance, then pass it in when you call compass():
h=compass(u, v, 'r', 'LineWidth', lineWidth); % lineWidth value computed in advance.