How to plot the exponentional function in matlab

Hello everyone
I want to plot this expression of probability in matlab y=exp(-(K-1)) in function of P[dB]. How can I do it? Please i need help.
I tried with this code but it doesn't go.
function y = Swb(K,p)
K=4;
y= exp(-(K-1));
end

답변 (2개)

Image Analyst
Image Analyst 2017년 10월 21일

0 개 추천

You need to use the plot() function.

댓글 수: 3

Birdman
Birdman 2017년 10월 21일
But he wants the psd of the function. Therefore doesn't he have to use pwelch?
Where does he say he wants the PSD? If he did, then yes, he'd use pwelch(). But I see him saying "I want to plot this expression...." and for that you'd use plot(). Of course his expression is just a single number since y = exp(-(K-1)) = exp(-(4-1)) = exp(-3) = 0.04978706.
I think he needs to read this link
Birdman
Birdman 2017년 10월 21일
I think you miss this part :
...in function of P[dB].

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

lakom Mariem
lakom Mariem 2017년 10월 23일

0 개 추천

Thanks all me,I want to reproduce this figure.For every single curve ,there is its own expression of probability.For example, for "SW" the expression of probability is Psw = exp(-(K-1)).Please can anyone help me how can i do it if you please and thanks in advance.

댓글 수: 6

WHAT figure? You forgot to attach it and you forgot to attach any data, like what is the p you send in when you call
y = Swb(K,p);
And why do you send in K when you immediately overwrite it with a value of 4?
@Image Analyst : thank you. About P it represents the power. honestly i'm new beginner at matlab and still don't know how to plot a curve..I want to plot the expression of probability (Prob = exp(-(K-1)) ) in function of P(P is the power [dB]).Please i need your help if you can.I tried with this code but i think it's wrong. function y = Swb(K,p)
K=4;
y= exp(-(K-1));
end
Do you mean like this:
p = linspace(0, 50, 500);
% Compute and plot for K=1
y = Swb(1, p);
subplot(2, 2, 1);
semilogy(p, y, 'LineWidth', 2);
grid on;
% Compute and plot for K=2
y = Swb(2, p);
subplot(2, 2, 2);
semilogy(p, y, 'LineWidth', 2);
grid on;
% Compute and plot for K=3
y = Swb(3, p);
subplot(2, 2, 3);
semilogy(p, y, 'LineWidth', 2);
grid on;
% Compute and plot for K=4
y = Swb(4, p);
subplot(2, 2, 4);
semilogy(p, y, 'LineWidth', 2);
grid on;
function y = Swb(K,p)
y = exp(-(K-1) * p);
end
thanks a lot. But I want just to know why do you modified this expression y=exp(-(K-1) * p); normally ti is just y=exp(-(K-1); why do you multiplied it by p (*p) ??
Thanks
If K is just a single number, like 4, then exp(-(K-1)) is just exp(-3), which is just 0.0497870683678639, not a whole curve. What would you have as the x coordinate?
Ok I understand.thanks a lot

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

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품

태그

질문:

2017년 10월 21일

댓글:

2017년 10월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by