필터 지우기
필터 지우기

how to make grid lines closer in xaxis and y axis

조회 수: 1 (최근 30일)
moonman
moonman 2011년 10월 16일
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
Jan
Jan 2011년 10월 16일
You code create the error "undefined Variable AX" in the "set(AX, ..." line. I assume you use "AX = subplot(2,1,1)"?

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2011년 10월 16일
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.
  댓글 수: 1
moonman
moonman 2011년 10월 16일
Thanks a lot Jan and u rightly said, it look cruel
I will follow the instructions of Walter

댓글을 달려면 로그인하십시오.

추가 답변 (3개)

Walter Roberson
Walter Roberson 2011년 10월 16일
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.
  댓글 수: 1
moonman
moonman 2011년 10월 16일
Thanks a lot Walter
I will follow what u said, it is easy to mark them by hand

댓글을 달려면 로그인하십시오.


moonman
moonman 2011년 10월 16일
I am getting this error when i pasted ur code in my code
??? Undefined function or variable 'AX'.
  댓글 수: 4
Jan
Jan 2011년 10월 16일
AX is undefined *and* has the value 173.0011?! Strange.
The numerical value seems to be a handle of a graphics object. This is an identification number, which allows to access the objects properties.
moonman
moonman 2011년 10월 16일
I have defined the AX
AX=subplot(2,1,1)
Then i get the value 173.0011
does this number give any information

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2011년 10월 16일
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. :)
  댓글 수: 1
moonman
moonman 2011년 10월 17일
Thanka a lot Walter for ur detailed answer

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by