- Load files Link
- Save the results v_ms,oat_k,bhp in array or cell array as per result data type
Looping with MATLAB Tables
9 views (last 30 days)
Show older comments
I have 10 different MATLAB Tables in my workspace. I wish to do the same operation to the 10 Table variables. I have written the code for 1 Table variable. Now I am wondering whether can I use a for loop to complete my work. But I don't know how to use a for loop for Table variables. Please help me.
%% Datasets from Experiments
load dataset
%% Finding BHP
%converting velocity from knots to m/s
v_ms = dataset7.v_k * 0.5144;
%converting outside air temperature(oat) from celcius to kelvin
oat_k = dataset7.oat_c + 273.15;
%finding brake horse power
bhp = (dataset7.rpm .* dataset7.mp_hg * Ts * rHP) ./ (rrpm * rmp * oat_k);
This is my code. The dataset file has 10 Tables like dataset1, dataset2 etc.
0 Comments
Accepted Answer
KALYAN ACHARJYA
on 21 Nov 2020
Steps:
load tables
v_ms(i)=zeros(1,length(tables_number));
oat_k(i)=zeros(1,length(tables_number));
bhp(i)=zeros(1,length(tables_number));
for i=1:length(tables_number)
%read first TABLE
filename=readtable(..); % Please refer the above link to call one by one file
v_ms(i)=
oat_k(i)=
bhp(i)=
end
I preseumed that, the v_ms,oat_k,bhp results are in single data(scaler), hence I used array here. If the results are any other types, please use cell array. In such case case you just to replace () with {}.
0 Comments
More Answers (0)
See Also
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!