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 CenterFile Exchange에서 Data 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