Azzera filtri
Azzera filtri

How to plot 3D ?

2 visualizzazioni (ultimi 30 giorni)
Ynne
Ynne il 13 Feb 2018
Commentato: Ynne il 14 Feb 2018
I want to use this below mentioned code to plot the distributions in 3D format, how can i fix it?
x = -6:0.01:6;
rho = [1 1.5 2 4 10];
p = [];
for k = 1:length(rho)
p = [p exp(-abs(x').^rho(k)) / (2*gamma(1+1/rho(k)))];
end
figure, hold on; set(gca,'fontsize',14);
plot(x,p,'linewidth',2);
str = num2str(rho');
clear str2;
for k = 1:length(rho)
str2(k,:) = ['\it\rho =' str(k,:)];
end
legend(str2); xlabel('\itx'); ylabel('\itGG(x\rm;\it\rho)'); xlim([-6 6])

Risposte (1)

Hossam Selim
Hossam Selim il 13 Feb 2018
Hi, what you are doing now is you apply the math to respective elements. however, in order to apply the math for all the combinations of elements in x and rho vectors. you need to use meshgrid and surf functions for making the plot you want. have a look at the modified code below. Hope this helps.
x= -6:0.01:6;
rho = [1 1.5 2 4 10];
[X,Y]=meshgrid(x,rho);
p = [exp(-abs(X).^Y) ./ (2*gamma(1+1./Y))];
figure
surf(X,Y,p);
  1 Commento
Ynne
Ynne il 14 Feb 2018
Thanks a lot.
But i want to have a 3D distribution for each rho, is this possible ?

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by