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

Antworten (1)

Hossam Selim
Hossam Selim am 13 Feb. 2018

0 Stimmen

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 Kommentar

Ynne
Ynne am 14 Feb. 2018
Thanks a lot.
But i want to have a 3D distribution for each rho, is this possible ?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Graphics Performance finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 13 Feb. 2018

Kommentiert:

am 14 Feb. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by