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

답변 (1개)

Hossam Selim
Hossam Selim 2018년 2월 13일

0 개 추천

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

Ynne
Ynne 2018년 2월 14일
Thanks a lot.
But i want to have a 3D distribution for each rho, is this possible ?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Graphics Performance에 대해 자세히 알아보기

질문:

2018년 2월 13일

댓글:

2018년 2월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by