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
2017 年 10 月 21 日
0 投票
You need to use the plot() function.
3 件のコメント
Birdman
2017 年 10 月 21 日
But he wants the psd of the function. Therefore doesn't he have to use pwelch?
Image Analyst
2017 年 10 月 21 日
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.
Birdman
2017 年 10 月 21 日
I think you miss this part :
...in function of P[dB].
lakom Mariem
2017 年 10 月 23 日
0 投票
6 件のコメント
Image Analyst
2017 年 10 月 23 日
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?
lakom Mariem
2017 年 10 月 24 日
Image Analyst
2017 年 10 月 24 日
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
lakom Mariem
2017 年 10 月 25 日
Image Analyst
2017 年 10 月 25 日
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?
lakom Mariem
2017 年 10 月 25 日
カテゴリ
ヘルプ センター および File Exchange で 2-D and 3-D Plots についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
