why do i get last value of loop?

1 visualizzazione (ultimi 30 giorni)
arian hoseini
arian hoseini il 10 Mar 2022
Risposto: Voss il 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

Risposta accettata

Voss
Voss il 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)

Più risposte (0)

Categorie

Scopri di più su Data Import and Export in Help Center e File Exchange

Tag

Prodotti


Release

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by