Calculate output row by row (Data Grid)

3 views (last 30 days)
Shahid Said
Shahid Said on 29 Apr 2021
Commented: Shahid Said on 30 Apr 2021
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?

Answers (1)

KSSV
KSSV on 29 Apr 2021
Read about table.
  1 Comment
Shahid Said
Shahid Said on 30 Apr 2021
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...

Sign in to comment.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!