get new column using existing columns

3 次查看(过去 30 天)
Amila
Amila 2022-7-22
评论: Amila 2022-7-22
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 个评论
Dyuman Joshi
Dyuman Joshi 2022-7-22
编辑:Dyuman Joshi 2022-7-22
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 2022-7-22
Thank you very very mutch its working

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Code Generation 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by