Combining Matrices from a loop into a single large Matrix
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm trying to find a shorter way to combine an increasing array of values that has to be inputted into several equations.
The only way I could think of based on my knowledge was a for loop like for example; This:
V9_eff2 = V9Split{2}+(((P9-Po).*A92)./mdot_core);
V9_eff3 = V9Split{3}+(((P9-Po).*A93)./mdot_core);
V9_eff4 = V9Split{4}+(((P9-Po).*A94)./mdot_core);
V9_eff5 = V9Split{5}+(((P9-Po).*A95)./mdot_core);
V9_eff6 = V9Split{6}+(((P9-Po).*A96)./mdot_core);
V9_eff7 = V9Split{7}+(((P9-Po).*A97)./mdot_core);
V9_eff8 = V9Split{8}+(((P9-Po).*A98)./mdot_core);
V9_eff9 = V9Split{9}+(((P9-Po).*A99)./mdot_core);
V9_eff10 = V9Split{10}+(((P9-Po).*A910)./mdot_core);
V9_eff11 = V9Split{11}+(((P9-Po).*A911)./mdot_core);
V9_eff12 = V9Split{12}+(((P9-Po).*A912)./mdot_core);
V9_eff13 = V9Split{13}+(((P9-Po).*A913)./mdot_core);
V9_eff14 = V9Split{14}+(((P9-Po).*A914)./mdot_core);
V9_eff15 = V9Split{15}+(((P9-Po).*A915)./mdot_core);
V9_eff16 = V9Split{16}+(((P9-Po).*A916)./mdot_core);
V9_eff17 = V9Split{17}+(((P9-Po).*A917)./mdot_core);
V9_eff18 = V9Split{18}+(((P9-Po).*A918)./mdot_core);
V9_eff19 = V9Split{19}+(((P9-Po).*A919)./mdot_core);
V9_eff20 = V9Split{20}+(((P9-Po).*A920)./mdot_core);
V9_effX = [V9_eff1; V9_eff2; V9_eff3; V9_eff4; V9_eff5; V9_eff6; V9_eff7; V9_eff8; V9_eff9; V9_eff10; V9_eff11; V9_eff12; V9_eff13; V9_eff14; V9_eff15; V9_eff16; V9_eff17; V9_eff18; V9_eff19; V9_eff20]
To be replaced by a loop however I would like to combine the loop iteration matrices into one large one, is there a way to do this in MATLAB?
0 commentaires
Plus de réponses (1)
James Tursa
le 22 Mai 2015
Modifié(e) : James Tursa
le 22 Mai 2015
Experienced MATLAB users cringe when we see code that has a boat load of variable names ending in numbers, like A92, A93, etc. The first thing we would advise is to rewrite your code to use cell arrays or struct arrays to contain your data and abandon this cumbersome variable naming approach you have taken. As you can see, it is fast becoming difficult to write code using all of those variable names. In order to write loops one ends up using the eval( ) function with dynamically created variable names. Very messy code that is hard to read and maintain. E.g., read this:
0 commentaires
Voir également
Catégories
En savoir plus sur Modulation dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!