get new column using existing columns

3 views (last 30 days)
Amila
Amila on 22 Jul 2022
Commented: Amila on 22 Jul 2022
I have to do two things
  1. I have a 13 colums and from that i need to compute value and make new column i have tried to do it like this but it give only zerows for each raw
  2. i need to save the file with the new column as 14 column data sheet
note: data set has about 1milion raws and 13 columns
the data is in a out put name Result2
Result2 = [D1, D2, D3, D4, D12, Ex, Az, Am, Te, IRR1, IRR2, IRR3, IRR4];
new colum i need is rat1
rat1 = (Result2(:,12). *2)/((Result2(:,11) + Result2(:,13))/2)
final output should be like below
Result3 = [D1, D2, D3, D4, D12, Ex, Az, Am, Te, IRR1, IRR2, IRR3, IRR4, rat1];
note since data file is two large this massage comes it asked to use matlab v7.3 or above please tel me the way i can generate the above Result3 file thank you verry mutch
  2 Comments
Dyuman Joshi
Dyuman Joshi on 22 Jul 2022
Edited: Dyuman Joshi on 22 Jul 2022
Dot is missing for element wise division.
Also, since the data is quite large, directly append the data as the last column, rather than storing it.
Result2 = [D1, D2, D3, D4, D12, Ex, Az, Am, Te, IRR1, IRR2, IRR3, IRR4];
Result2 = [Result2 2*Result2(:,12)./(Result2(:,11) + Result2(:,13))/2];
%or
Result2(:,14)=2*Result2(:,12)./(Result2(:,11) + Result2(:,13))/2;
I think the latter would be faster.
Amila
Amila on 22 Jul 2022
Thank you very very mutch its working

Sign in to comment.

Answers (0)

Categories

Find more on Code Generation in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!