Calculate output row by row (Data Grid)

조회 수: 8 (최근 30일)
Shahid Said
Shahid Said 2021년 4월 29일
댓글: Shahid Said 2021년 4월 30일
Hello,
I would like to calculate all the row value based on formula and get the output row by row which at new column.because I need to use more than 10 formula by refer to the my which generated by combination as below.
I change from meshgrid to ngrid as below and I can get result as expected 400k rows.
because meshgrid cannot support more than 3 variable.
[a,b,c,d,e]=ndgrid(1:20,1:20,1:10,1:10,1:10);
data=[a(:),b(:),c(:),d(:),e(:)];
Car={'C1', 24 , 8.86 , 9.37 , 38.65 , 31.61 , 280 , 25 , -0.0033 , -0.004 , 0.058 , 45 , 0.97;...
'C2', 24 , 8.68 , 9.37 , 38.6 , 32.4 , 280 , 25 , -0.0034 , -0.004 , 0.057 , 46.5 , 0.98;...
more data
Lamp= {'Lamp1', 24 , 200;...
'Lamp', 24 , 200;...
more data
Seat={'1',147 , 32 , 145;...
'S2', 138 , 120 , 140;...
more data
and 2 more variable
ExpandData=[Car(data(:,1),:), Lamp(data(:,2),:), Seat(data(:,3),:), Bumper(data(:,4),:), Spoiler(data(:,4),:)]
Example :
Speed = C1 Column no 2 row 1 .* L1 Column 2 row 1 .* Seat Column1 row 1
anybody can help me?

답변 (1개)

KSSV
KSSV 2021년 4월 29일
Read about table.
  댓글 수: 1
Shahid Said
Shahid Said 2021년 4월 30일
clc
clear
%Create Combination
[a,b,c,d,e]=ndgrid(1:2,1:2,1:2,1:2,1:2);
data=[a(:),b(:),c(:),d(:),e(:)];
PV={'PV1',1,2,3,4,5;...
'PV2',1,2,3,4,5};
Batt={'B1',1,2,3,4,5;...
'B2',1,2,3,4,5};
MPPT={'MPPT1',1,2,3,4,5;...
'MPPT2',1,2,3,4,5};
Inverter={'Inv1',1,2,3,4,5;...
'Inv2',1,2,3,4,5};
DieselGenerator={'DG1',1,2,3,4,5;...
'DG2',1,2,3,4,5};
ExpandData1=[PV(data(:,1),:), Batt(data(:,2),:), MPPT(data(:,3),:), Inverter(data(:,4),:), DieselGenerator(data(:,5),:)]
table = ExpandData1(:,3);
table2 = ExpandData1(:,4);
output = ExpandData1(:,3)* ExpandData1(:,4)
error at last line...

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

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by