フィルターのクリア

Getting blank plot in MATLAB

19 ビュー (過去 30 日間)
Satish Jawalageri
Satish Jawalageri 2020 年 7 月 14 日
コメント済み: Satish Jawalageri 2020 年 7 月 15 日
Hi, could I know where I might be wrong in the following code as Im getting blank graph. The parameter vel and acc are time dependent which in turn Fh is function of time.
function [Fh] = hydro(t)
Cd = 0.6;
Ca = 0.9699;
R = 4.7;
for t=0:0.1:10
vel = compute_wavevelocity(t)
acc = compute_waveacceleration(t)
fun = sym((0.5*997*Cd*2*R*abs(vel)*vel)+(Ca*997*pi*(R^2)*acc)+(pi*(R^2)*997*acc));
Fh(t==0:0.1:10) = eval(int(fun,0,-120));
end
plot(t,Fh), xlabel('time(s)'), ylabel('Fh')
title ('Fh vs Time')
end
  4 件のコメント
Image Analyst
Image Analyst 2020 年 7 月 14 日
Do you really even need symbolics? Or could you do it numerically, something like this:
Cd = 0.6;
Ca = 0.9699;
R = 4.7;
all_t=0:0.1:10
for k = 1 : length(all_t)
t = all_t(k);
vel = compute_wavevelocity(t)
acc = compute_waveacceleration(t)
fun = (0.5*997*Cd*2*R*abs(vel)*vel)+(Ca*997*pi*(R^2)*acc)+(pi*(R^2)*997*acc);
Fh(k) = fun;
end
plot(all_t,Fh), xlabel('time(s)'), ylabel('Fh')
title ('Fh vs Time')
Satish Jawalageri
Satish Jawalageri 2020 年 7 月 15 日
Thanks for your reply.
I will check this but here Fh is integration of fun.

サインインしてコメントする。

回答 (1 件)

Cris LaPierre
Cris LaPierre 2020 年 7 月 14 日
This is because t is a scalar. When you plot, it has the value it was assigned on the last loop of the for loop: 10.
Try changing the x input in your plot command:
plot(0:0.1:10,Fh)
  13 件のコメント
Cris LaPierre
Cris LaPierre 2020 年 7 月 15 日
These appear to be new questions. I suggest creating a new post for each.
Satish Jawalageri
Satish Jawalageri 2020 年 7 月 15 日
Sure, I will.
Thanks.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by