Cómo mostrar un número fijo de coordenadas en el eje x en matlab
=========plot_to_center.m=====
función plot_too_center(x,y,xticks,yticks)
%by faruto@www.ilovematlab.cn QQ:516667408 Correo electrónico:farutoliyang@gmail.com
%2009.7.11
hp = plot(x,y );
xl = xLim;
yl = yLim;
xt = get(gca,' XTick');
yt = get( gca,'YTick');
if nargin == 2
xticks = xt;
yticks = yt;
else
xt = xticks;
yt = yticks;
if xl(1)>min(xticks)
xl( 1) = min(xticks);
fin
si xl(2)<max(xticks)
xl(2) = max(xticks) ;
fin
si yl(1)>min(yticks)
yl(1) = min(yticks);
fin
if yl(2) yl(2) = max(yticks); fin fin xep = 1/(xl(2)-xl(1)); yep = 1/(il(2)-il(1)); p = get (gca,'Position'); set(gca,'XTick',,'LineWidth',2); annotation('arrow',,'LineWidth); ', 2); y = ,'LineWidth',2); annotation('arrow',,'LineWidth',2); para i = 1:longitud(xticks) x = ,'LineWidth',2); text(xticks(i),( yl(1)+yl(2) )/ 2-0.04*1/yep,num2str( xticks(i)),'Fontsize',12,... 'Color',); end p> para i = 1:longitud(yticks) x = [( xl(1)+xl(2) )/2 ( xl(1)+xl(2) )/2 +0.02 *1/xep]; y = [ yticks(i),yticks(i)]; line(x,y,'Color',,'LineWidth' ,2 ); text((( xl(1)+xl(2) )/2-0.065*1/xep,yticks(i),num2str( yticks(i)),'Fontsize' ,12 ,... 'Color',); finalizar cuadrícula en ======= == ============== ================== ==========plot_to_anywhere.m ============ función plot_to_anywhere(x,y,xticks,yticks) %por faruto@www.ilovematlab.cn QQ:516667408 Correo electrónico: farutoliyang@ gmail.com %2009.7.11 hp = plot(x,y); [xyuan,yyuan] = ginput(1); xl = xLim; yl = yLim; xt = get(gca,' XTick'); yt = get(gca,'YTick'); si nargin == 2 xticks = xt; p> yticks = yt; else xt = xticks yt = yticks; if xl(1)>min; (xticks) xl(1) = min(xticks); fin si xl(2)<max(xticks) xl(2) = max(xticks); fin si yl(1)>min(yticks) yl(1) = min(yticks) ; fin si yl(2) yl(2) = max(yticks); fin fin xep = 1/(xl(2)-xl(1) yep = 1/(il(2)-ilo); (1)); p = get(gca,'Position'); set(gca,'XTick',[],'XColor','w'); set(gca,'YTick',[],'YColor','w') x = [xl(1) xl(2)]; y = [( yl(1) + yl(2) )/2+yyuan ( yl(1) + yl(2) )/2 + yyuan]; line(x, y,'Color',,'LineWidth',2); annotation('arrow',[p(1)+p(3),p(1)+p(3)+0.02] ,[p(2)+p(4)/2+yyyuan*yep*p(4),p(2)+p(4) /2+yyuan*yep*p(4)],... p> 'Color',,'Ancho de línea',2); y = [yl(1) yl(2)]; x = [( xl (1)+xl(2) )/2+xyuan ( xl(1)+xl(2) )/2+xyuan]; line(x,y,...'Color', ,'LineWidth',2); annotation('arrow',[p(1)+p(3)/2+xyuan*xep*p(3),p(1)+p( 3)/2+xyuan*xep*p(3)],[p(2)+p(4),p(2)+p (4)+0.02],... ' Color',,'LineWidth',2); for i = 1:length(xticks) x = [x ticks(i),xticks(i)]; y = [( yl(1)+yl(2) )/2+yyuan ( yl(1)+yl(2) )/2+ yyuan+0.02*1/sí]; line(x,y,'Color',,'LineWidth',2); text(xticks(i),( yl (1)+yl(2) )/2+yyuan-0.04*1 /yep,num2str(xticks(i)),'Fontsize',12,... 'Color',); fin para i = 1:longitud(yticks) x = [( xl(1)+xl(2) )/2+xyuan ( xl(1)+xl(2) )/2+xyuan+0.02*1/xep]; y = [yticks(i),yticks(i)]; line(x,y,'Color',,'LineWidth',2); text(( xl(1)+xl(2) )/2+xyuan-0.065*1/xep,yticks (i) )/2+xyuan-0.065*1/xep,yticks(i),num2str(yticks(i)),'Fontsize',12,... 'Color',); finalizar cuadrícula en =========================== ==================================