フィルターのクリア

Code gives Loop function error

2 ビュー (過去 30 日間)
Ashish Sharma
Ashish Sharma 2022 年 6 月 6 日
編集済み: Torsten 2022 年 6 月 7 日
Hello friends,
Trying to write code for a FEM model, stuck on loop function. Basically want to write a simple function first where F(t) = 500 at t=0 and decreases as a linear function in increments of dt=0.1, to be F(t) =0 at t=0.5. I'll then use these F0, F1,... values for further calculations. Can you please advise where am I going wrong?
Ta!
Ash
Error in 5514 (line 25)
F(i+1)=F(i)-100;
clear all;
close all;
clc;
F0=500;
for i=0:0.1:0.5;
F(i+1)=F(i)-100;
if F(i+1)<=0;
break
end
end

回答 (1 件)

Torsten
Torsten 2022 年 6 月 6 日
編集済み: Torsten 2022 年 6 月 6 日
t = 0:0.1:0.5;
F = 500 - 1000*t;
  2 件のコメント
Ashish Sharma
Ashish Sharma 2022 年 6 月 7 日
Hi Torsten,
I need all 5 instances of F i.e. F1 thru F5, That's why I have used as F(i+1) = F(i)-100*i; I want the code to find the value of F based on previous value. Thoughts?
Torsten
Torsten 2022 年 6 月 7 日
編集済み: Torsten 2022 年 6 月 7 日
F(1) = 500;
for i = 1:5
F(i+1) = F(i) - 100;
end

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

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by