Need help in converting R code to Matlab Code.

3 件のコメント

Walter Roberson
Walter Roberson 2020 年 3 月 3 日
What error message did you receive when you attempted to implement the code?
ZAINULABADIN ZAFAR
ZAINULABADIN ZAFAR 2020 年 3 月 3 日
I don't know how to convert it into Matlab. If you please convert it into Matlab, I will be appreciated.Thanks
Walter Roberson
Walter Roberson 2020 年 3 月 3 日
You convert it to MATLAB by writing the MATLAB equivalent of each line. Except perhaps the line that sets plotting parameters: that does not appear to have a good correspondence with MATLAB.

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

 採用された回答

KSSV
KSSV 2020 年 3 月 3 日

0 投票

lam=0.01 ;
d=0.8 ;
reps=21 ;
rvec=linspace(0,10,reps) ; % vector of R0 values
inf=zeros(1,length(rvec)) ;; % empty vector to save infected density
ct=1; % just a counter to be able to index vectors
for i = 1:length(rvec) % #loop over R0 values
Rn = rvec(i) ;
if(Rn<1)
I=0 ; % if R0 is less than 1, no equilbirum infecteds
else
I=d*(Rn-1)/lam ; %equilibrium infecteds on page 60
end
inf(i) = I ; % record this for each value of R0
end
plot(rvec,inf) % p

2 件のコメント

ZAINULABADIN ZAFAR
ZAINULABADIN ZAFAR 2020 年 3 月 3 日
thanks
KSSV
KSSV 2020 年 3 月 3 日
Thanks is accepting the asnwer.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeBiological and Health Sciences についてさらに検索

質問済み:

2020 年 3 月 3 日

コメント済み:

2020 年 3 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by