why do i get last value of loop?

1 vue (au cours des 30 derniers jours)
arian hoseini
arian hoseini le 10 Mar 2022
Réponse apportée : Voss le 10 Mar 2022
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

Réponse acceptée

Voss
Voss le 10 Mar 2022
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)

Plus de réponses (0)

Catégories

En savoir plus sur Data Import and Export dans Help Center et File Exchange

Tags

Produits


Version

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by