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])

Réponses (1)

Hossam Selim
Hossam Selim le 13 Fév 2018

0 votes

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 commentaire

Ynne
Ynne le 14 Fév 2018
Thanks a lot.
But i want to have a 3D distribution for each rho, is this possible ?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Graphics Performance dans Centre d'aide et File Exchange

Question posée :

le 13 Fév 2018

Commenté :

le 14 Fév 2018

Community Treasure Hunt

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

Start Hunting!

Translated by