How to create a loop that runs through the rows of a table?
Ältere Kommentare anzeigen
I am trying to create a loop that runs through a table (2016 x 2) that takes the data from each column and inputs it into an equation and plots each result for each row. This is what I have attempted so far however, I am struggling to get this to work. Any help would be greatly appreciated.
rows = height(T);
for row = 1:rows
a1=T(row,1);
a2=T(row,2);
P=a1*a2;
end
hold on
plot(p,row)
Akzeptierte Antwort
Weitere Antworten (1)
ANKUR KUMAR
am 16 Mär. 2021
Bearbeitet: ANKUR KUMAR
am 16 Mär. 2021
clc
clear
A=randi(20,25,5); %generating random data
T = array2table(A);
equation= @(x) x*5 + log(x) % creating an equation
names=T.Properties.VariableNames;
for kk=1:length(names)
values=T(:,names{kk});
plot(equation(values{:,:}))
hold on
end
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
