why do i get last value of loop?

1 回表示 (過去 30 日間)
arian hoseini
arian hoseini 2022 年 3 月 10 日
回答済み: Voss 2022 年 3 月 10 日
clc
clear
In = input;%this is my data
tms = 0.5;
psm1 = 1.1:20;
for i = 1:length(psm1) %my problem is here >>>>first i tried psm1 here but i got only last value so i wrote this
k1 = In(1,1);
alfa1 = In(1,2);
betta1 = In(1,3);
t(i) = ((k1 + betta1)/(i^alfa1 - 1))*tms
end
plot(psm1,t)
as u see i need i=1.1:length(psm1) but i dont know what to do

採用された回答

Voss
Voss 2022 年 3 月 10 日
Is this what you want to do?
clc
clear
% In = input;%this is my data
In = [2 3 4]; % using some arbitrary values
tms = 0.5;
psm1 = 1.1:20;
for i = 1:length(psm1) %my problem is here >>>>first i tried psm1 here but i got only last value so i wrote this
k1 = In(1,1);
alfa1 = In(1,2);
betta1 = In(1,3);
% t(i) = ((k1 + betta1)/(i^alfa1 - 1))*tms
t(i) = ((k1 + betta1)/(psm1(i)^alfa1 - 1))*tms;
end
plot(psm1,t)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import and Export についてさらに検索

タグ

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by