Trying to use Array Calculations

조회 수: 12 (최근 30일)
Thallon Pitchure
Thallon Pitchure 2020년 1월 28일
댓글: Mohammad Sami 2020년 1월 28일
Hello!
I am trying to do calculations from data import from a .csv file. I mport the code and filter it to make an array with the data that is necessary for my calculations. I am trying to take each column and square each row of the column and then I would like to store the solution in a new column next to the input. If I am unclear I apologize. My goal is to take Ank_Pow1, Ank_pow2, and Ank_Pow_Gen; then square each cell and store the found value in the cell next to input.
I was trying to use T.TestAvg = mean(T{:,2:end},2) as my example but I do not understand the ,2 past the { }. If someone could explain please and also the example does row calulations and not column. If you could please help, I would greatly appreciate it. Thank you and have a pleasant day.
This is the code I have so far.
tbl_unfiltered = readtable([pathname filename], 'ReadVariableNames', 1);
tbl_all_variables = tbl_unfiltered (1:36,[4 5 6 8]);
tbl_Control = tbl_unfiltered(18:36,4:6);
tbl_COPD = tbl_unfiltered(1:16,4:6);
tbl_Cont_speed = tbl_unfiltered(18:36,8);
tbl_COPD_speed = tbl_unfiltered(1:16,8);
Control_array = table2array(tbl_Control);
COPD_array = table2array(tbl_COPD);
Control_sum = sum(Control_array);
COPD_sum = sum(COPD_array);
and this is a sample of my input data.
  댓글 수: 1
Mohammad Sami
Mohammad Sami 2020년 1월 28일
For squaring the elements use .^2
t.var1_2 = t.var1.^2;
For reorderign the columns
t = t(:,[4 3 2 1]); % change the col orders. 4th column comes first.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by