why do i get last value of loop?

1 visualización (últimos 30 días)
arian hoseini
arian hoseini el 10 de Mzo. de 2022
Respondida: Voss el 10 de Mzo. de 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

Respuesta aceptada

Voss
Voss el 10 de Mzo. de 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)

Más respuestas (0)

Categorías

Más información sobre Data Import and Export en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by