Code Explaination (For Loop)
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Mortuza Antu
am 17 Jan. 2020
Beantwortet: Walter Roberson
am 17 Jan. 2020
function [y]=f6(x)
global data
x=abs(x);
n=length(data(:,1));
for i=1:n-1
if x(i)>1;
x(i)=1;
else
end
P(i)=data(i+1,4)+x(i)*(data(i+1,5)-data(i+1,4));
end
Can anyone explain the for loop please?
My data is a 3x5 matrix & i'll use it for genetic algorithm.
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 17 Jan. 2020
The code is doing linear interpolation between column 4 and column 5, using abs(x) as the portion of the way between the columns.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!