how to make grid lines closer in xaxis and y axis
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have written this code
h1336=[];
L=50;
fs=8000;
fb=1336;
h1336 = (2/L)*cos(2*pi*fb*(0:L-1)/fs);
[H,F] = freqz(h1336,1,[],fs);
subplot(2,1,1)
plot(F./1000,20*log10(abs(H)));
grid on;
set(AX,'XMinorGrid','on')
xlabel('kHz'); ylabel('Magnitude-squared (dB)');
title('Magnitude Response of h1336 for L=50')
*
I want to have grid after every interval of .1 on xaxis and after every 1 on y-axis
how can i do this*
1 comentario
Jan
el 16 de Oct. de 2011
You code create the error "undefined Variable AX" in the "set(AX, ..." line. I assume you use "AX = subplot(2,1,1)"?
Respuesta aceptada
Jan
el 16 de Oct. de 2011
XLimits = get(AX, 'Xlim');
YLimits = get(AX, 'Ylim');
set(AX, 'XTick', XLimits(1):0.1:XLimits(2), ...
'YTick', YLimits(1):1:YLimits(2));
It looks cruel.
Más respuestas (3)
Walter Roberson
el 16 de Oct. de 2011
The only way to directly control the minor tick spacing on an axes is to draw the ticks in yourself (that is, by drawing lines in the positions you want the ticks to go.)
The documentation indicates that the number of minor ticks is determined automatically by the spacing of the major ticks. You can control the positions of the major ticks by setting XTick or YTick to a vector of values of where you want the ticks to be positioned. MATLAB might then happen to place the minor ticks where you want, but if it does not all you can do is draw them yourself.
When I encounter situations such as this, about the first thing I do is look at the File Exchange contribution plt which is much more flexible.
Walter Roberson
el 16 de Oct. de 2011
Yes, the graphics handle number does give information, the information it gives is undocumented and completely subject to change between releases and even during the execution of any one program.
In the above case, the known information that it conveys is "this graphics object is most likely to be an axes". And that's about it, as far as anyone is willing to publicly admit.
The situation is about like going to a cafe' that offers take-out beverages in a variety of colorful paper cups, with the staff having arranged a pile of the cups near the latte machine, another pile near the coffee machine, and another pile near the tea machine. When the staff makes a take-out beverage, they grab the top cup on the pile nearest to where they are working. If a pile runs out and another pile is nearby, they use that instead until there is time to stock up more, which the staff does by grabbing another stack of cups from the bag.
You can see, if you think about such a situation, that the color of the cup used for any one beverage might change several times during a shift, and that there might be times when the tea pile is used for latte so no cup color is a promise, but if you were to ask a bunch of people what color of cup they got and what kind of beverage they got, then over the short term you could make good guesses about what kind of beverage people got by looking at the color of their cup.
Likewise, if you bother to study enough graphics handles, you will find that there are short-term correlations in the numbering that can hint about the kind of graphics object and about its likely relationship to other objects.
Is this information of any practical use? Probably not. But you only asked if it gave information, not if there was any value in the information. :)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!