How to plot smooth graph?
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Hi, I was stuck here.. can someone help me out? How do I make the Pbat1 and Pbat2 smooth?
P_load = [0,8000,10000,11000,20000,25000,25000,21000,30000,20000,12000,45000,12000,45000,23300,12000,15000,17000,20000,16000,12200,1000,2000,100];% Watts
plot(P_load,'linewidth', 2)
P_gen = ones(1,24).*29000; % Watts
P_lowerlimit = ones(1,24).*10000; % Watts
hold on
plot(P_gen, 'linewidth', 2)
plot(P_lowerlimit, 'linewidth', 2)
grid
xlim([1,24])
xlabel('Time (hours)')
ylabel('Power (Watts)')
hold on
Pnet1 = [];
Pbat1 = [];
Pnet2 = [];
Pbat2 = [];
for h = 1:24
Pnet1(h) = P_gen(h) - P_load(h);
Pnet2(h) = P_lowerlimit(h) - P_load(h);
if Pnet1(h) > 0
Pbat1(h) = 0;
else
Pbat1(h) = P_load(h) - P_gen(h);
end
if Pnet2(h) < 0
Pbat2(h) = 0;
else
Pbat2(h) = [P_gen(h) - P_load(h)]/3;
end
end
plot(Pbat1, 'linewidth', 3)
plot(Pbat2, 'linewidth', 3)
legend('Load','Generator','Lower limit','Battery energy(Discharge)','Battery energy(Charge)')
If possible, i need with spline code. Help appreciated, thank you.
採用された回答
madhan ravi
2018 年 11 月 1 日
編集済み: madhan ravi
2018 年 11 月 1 日
P_load = [0,8000,10000,11000,20000,25000,25000,21000,30000,20000,12000,45000,12000,45000,23300,12000,15000,17000,20000,16000,12200,1000,2000,100];% Watts
x=1:numel(P_load)
xx=linspace(1,numel(x),1000)
yy=interp1(x,P_load,xx,'pchip')
plot(x,P_load,'*g',xx,yy,'-k','linewidth', 2)
P_gen = ones(1,24).*29000; % Watts
P_lowerlimit = ones(1,24).*10000; % Watts
hold on
xx=linspace(1,numel(x),1000)
yy=interp1(x,P_gen,xx,'spline')
plot(x,P_gen,'og',xx,yy,'-m','linewidth', 2)
xx=linspace(1,numel(x),1000)
yy=interp1(x,P_lowerlimit,xx,'spline')
plot(x,P_lowerlimit,'or',xx,yy,'-b','linewidth', 2)
grid
xlim([1,24])
xlabel('Time (hours)')
ylabel('Power (Watts)')
hold on
Pnet1 = [];
Pbat1 = [];
Pnet2 = [];
Pbat2 = [];
for h = 1:24
Pnet1(h) = P_gen(h) - P_load(h);
Pnet2(h) = P_lowerlimit(h) - P_load(h);
if Pnet1(h) > 0
Pbat1(h) = 0;
else
Pbat1(h) = P_load(h) - P_gen(h);
end
if Pnet2(h) < 0
Pbat2(h) = 0;
else
Pbat2(h) = [P_gen(h) - P_load(h)]/3;
end
end
xx=linspace(1,numel(x),1000)
yy=interp1(x,Pbat1,xx,'spline')
plot(x,Pbat1,'ok',xx,yy,'-y','linewidth', 3)
xx=linspace(1,numel(x),1000)
yy=interp1(x,Pbat2,xx,'spline')
plot(x,Pbat2,'oc',xx,yy,'-r','linewidth', 3)
legend('Load','Generator','Lower limit','Battery energy(Discharge)','Battery energy(Charge)')
14 件のコメント
madhan ravi
2018 年 11 月 1 日
use the same method like last time
madhan ravi
2018 年 11 月 1 日
if something is not clear let me know
Ain Athirah
2018 年 11 月 1 日
編集済み: Ain Athirah
2018 年 11 月 1 日
Thank you so much... I will learn how you do that. :) sure will let you know.
madhan ravi
2018 年 11 月 1 日
Anytime :)
Ain Athirah
2018 年 11 月 1 日
In the previous one,
plot(x,P_load,'or',xx,yy,'-m', 'linewidth', 2)
What is the us of 'or' and '-m', and also this one:
plot(x,P_load,'*g',xx,yy,'-k','linewidth', 2)
'*g' and '-k'. What is the use of this symbol ' . Thanks :D
madhan ravi
2018 年 11 月 1 日
編集済み: madhan ravi
2018 年 11 月 1 日
They are markers , read the below link for more explanation https://www.mathworks.com/help/matlab/ref/linespec.html
Ain Athirah
2018 年 11 月 1 日
Do you have a link for me to get to know about that?
madhan ravi
2018 年 11 月 1 日
See the previous comment
Ain Athirah
2018 年 11 月 1 日
Oh, i already know, it is for colour and line for the points. THHANKS.. yoou give me the hint, i change the code.
madhan ravi
2018 年 11 月 1 日
You’re welcome
Ain Athirah
2018 年 11 月 1 日
sorry, i didnt update your answer, thanks a lot!
Ain Athirah
2018 年 11 月 1 日
編集済み: Ain Athirah
2018 年 11 月 1 日
I have a new problem now on how to label them? by using legend code, seems it be different between points and line.. see the picture:

How to make them be one? as they need to be. Thanks :D
madhan ravi
2018 年 11 月 1 日
Please ask a separate question
Ain Athirah
2018 年 11 月 1 日
okay
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Spline Postprocessing についてさらに検索
タグ
タグが未入力です。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
