Looping with MATLAB Tables

3 ビュー (過去 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 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by