how to set different axis value?
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    U B
 el 14 de Feb. de 2023
  
    
    
    
    
    Respondida: Tiisetso Jeanet
 el 21 de Abr. de 2024
            I want to change the axis display value in a  contour plot.
   xylim = 0.0055 ;
   N = 5; x = linspace(-xylim,xylim,N); y = x; 
   [X,Y] = meshgrid(x,y);
    r = (X.^2 + Y.^2); rho = sqrt(r);
    f = 0.011 ; 
    theta = atan(rho./f) ;
    CPhi = X./rho; SPhi = Y./rho; 
     if mod(N,2) == 1
        CPhi((N-1)/2+1,(N-1)/2+1) = 1; 
        SPhi((N-1)/2+1,(N-1)/2+1) = 0; 
     end 
%% Function
    n1 = 1; 
    n2 = 1.5     ; 
    thetaI = theta;
    Th = theta*180/pi;
    thetaT = asin((n1./n2).*sin(thetaI));   
    CTi = cos(thetaI);
    CTt = cos(thetaT); 
    a = (n2.*CTi - n1.*CTt) ;      
    b = (n2.*CTi + n1.*CTt) ;
    c = (n1.*CTi - n2.*CTt) ;
    d = (n1.*CTi + n2.*CTt) ;
    Rp = a./b;
    Rs = c./d;
figure,contourf(X,Y,Rp,20);
Now the x and y axis has value -5 to +5 mm, from the below image we can see. I want to change the axis value from X and Y to the value of the red cross line of the Th value chart(below image) which is a function of X and Y. So new x axis should be [26.5651    14.0362    0    140362    26.5651}  and new y axis [26.5651    14.0362    0    140362    26.5651}. can anyone help me please? Thank you.

0 comentarios
Respuesta aceptada
  Kevin Holly
    
 el 14 de Feb. de 2023
        xylim = 0.0055 ;
   N = 5; x = linspace(-xylim,xylim,N); y = x; 
   [X,Y] = meshgrid(x,y);
    r = (X.^2 + Y.^2); rho = sqrt(r);
    f = 0.011 ; 
    theta = atan(rho./f) ;
    CPhi = X./rho; SPhi = Y./rho; 
     if mod(N,2) == 1
        CPhi((N-1)/2+1,(N-1)/2+1) = 1; 
        SPhi((N-1)/2+1,(N-1)/2+1) = 0; 
     end 
%% Function
    n1 = 1; 
    n2 = 1.5     ; 
    thetaI = theta;
    Th = theta*180/pi;
    thetaT = asin((n1./n2).*sin(thetaI));   
    CTi = cos(thetaI);
    CTt = cos(thetaT); 
    a = (n2.*CTi - n1.*CTt) ;      
    b = (n2.*CTi + n1.*CTt) ;
    c = (n1.*CTi - n2.*CTt) ;
    d = (n1.*CTi + n2.*CTt) ;
    Rp = a./b;
    Rs = c./d;
figure,contourf(X,Y,Rp,20);
h=gca;
% X Axis
h.XTick = [-0.0055,-0.0028,0,0.0028,0.0055];
newx = [26.5651    14.0362    0    140362    26.5651];
h.XAxis.TickLabels = {newx};
% Y Axis
h.YTick = [-0.0055,-0.0028,0,0.0028,0.0055];
newy = [26.5651    14.0362    0    140362    26.5651];
h.YAxis.TickLabels = {newx};
1 comentario
  Walter Roberson
      
      
 el 14 de Feb. de 2023
				this is the changing labels option that I mentioned. As I noted it does not change coordinates for data tips. Or for ginput or similar.
Más respuestas (2)
  Walter Roberson
      
      
 el 14 de Feb. de 2023
        there are two different things you might mean.
If you want to change the actual x and y coordinates to the ones you indicated then you will have problems because your coordinates are not sorted and you would be warping the contour over an irregular surface. It could be done if strictly necessary, but it would take some work to transform the contour into something that could be warped over a surface.
But possibly you just want to change the x and y labels. You can do that by calling xtick and ytick and xlabel and ylabel routines. This would only change the decoration and would not for example affect datatips
0 comentarios
  Tiisetso Jeanet
 el 21 de Abr. de 2024
        how to make the x-axis have have an interval running from 1990:2022 having space of 5
e.g 1990,1995
0 comentarios
Ver también
Categorías
				Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




