Clear Filters
Clear Filters

How to flip the x axis in a 3d plot?

22 views (last 30 days)
Hello Everyone
I need help regarding how to plot the x or y or maybe z axis values in backward mode. Like instead of it starts at 0 it will start at its maximum value and finish at minimum value. It would be best for me to explain with visual demontration.
My Plot:
The plot I want:
In the below image , the x axis starts at 90 and end at 0. I want my x axis to start at 180 and end at 0.
My code:
clc
clear
close all
f=13.56e6; % Fundamental Frequency
T=1/f; % Fundamental Period
omega=2*180*f;
t=0:T*.0001:T;
%************************Triple Fequency Case****************%
k=3; % Number of consecutive Harmonics
Total_Applied_Voltage=300;
V0=(2*Total_Applied_Voltage)/(k+1);
V=nan(1,k);
Omega=nan(1,k);
V_rf=0;
for n=1:1:k
V(n)=V0*(k-n+1)/(k);
Omega(n)=n*omega;
end
theta2=0:5:180;
discharge_symmetry=linspace(0,1,length(theta2));
Dc_Self_Bias = nan(length(theta2), length(discharge_symmetry));
for x=1:1:length(discharge_symmetry)
for y=1:1:length(theta2)
Vrf=V(1)*cosd(Omega(1)*t)+V(2)*cosd(Omega(2)*t+theta2(y))+V(3)*cosd(Omega(3)*t);
Dc_Self_Bias(y,x)=-(((max(Vrf)+(discharge_symmetry(x)*min(Vrf)))/(1+discharge_symmetry(x)))/Total_Applied_Voltage)*100;
end
end
figure(1)
hsc = surfc(theta2, discharge_symmetry, Dc_Self_Bias);
% hsc(1).EdgeColor = 'interp'; % Surface Plot
hsc(2).EdgeColor = 'black';
hsc(2).ZLocation = 'zmin'; % Contour Plot
hsc(2).FaceColor = 'flat';
colormap("turbo");
colorbar
xlabel(['\theta_2 ',char(176),''])
ylabel('discharge symmetry')
zlabel('Dc Self Bias %')
title('Discharge Characteristics')
xlim([min(theta2), max(theta2)])
ylim([min(discharge_symmetry), max(discharge_symmetry)])
zlim([min(min(Dc_Self_Bias))-10, 40])
xticks(min(theta2):30:max(theta2))
yticks(min(discharge_symmetry):0.1:max(discharge_symmetry))
pbaspect([1 1 1])
grid on
grid minor

Accepted Answer

Bruno Luong
Bruno Luong on 19 Apr 2024
Edited: Bruno Luong on 19 Apr 2024
Do set(gca,'XDir','reverse') one the surfc command is carried out
s = peaks';
subplot(1,2,1)
surfc(s)
xlabel('x')
subplot(1,2,2)
surfc(s)
set(gca,'XDir','reverse')
xlabel('x')

More Answers (0)

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!