Looping with MATLAB Tables

조회 수: 10(최근 30일)
JPS
JPS 2020년 11월 21일
답변: KALYAN ACHARJYA 2020년 11월 21일
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.

채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2020년 11월 21일
Steps:
  1. Load files Link
  2. Save the results v_ms,oat_k,bhp in array or cell array as per result data type
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개)

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by