MATLAB Answers

First time user Need help with evaluating equation for several different possiblities.

26 views (last 30 days)
Hayden Aylor
Hayden Aylor on 29 Jun 2020 at 19:25
Commented: Rik on 30 Jun 2020 at 13:57
I have an equation (9*a) + (12.5*b) + (15*c) + (17*d) + (20*e) + (22.5*f) + (27*g) + (30*h) + (35*j) where a = 1:143 b = 1:100 c = 1:80 d = 1:67 e = 1:57 f = 1:40 g = 1:34 h = 1:29 I want to evaluate the expression for all of the possible comninations of all arrays.

  6 Comments

Show 3 older comments
Benjamin
Benjamin on 30 Jun 2020 at 13:39
It is a very large number of combinations (172310835840000*NJ, where NJ is the number of values j can have (unspecified in the question), which is ~ 64000*NJ GB of memory, assuming single-precision floating-point numbers). I can't imagine a 9-dimensional array of this size would fit in RAM; how do you intend to store the resulting values? The answer to this question will dictate the possible solutions.
Rik
Rik on 30 Jun 2020 at 13:57
It should be possible to efficiently find the histogram of the resulting evaluations, but I don't immediately see how you would do that. The code below is probably a good start.
a=[1 143];
b = [1 100];
c = [1 80];
d = [1 67];
e = [1 57];
f = [1 40];
g = [1 34];
h = [1 29];
j=1;
[a,b,c,d,e,f,g,h,j]=ndgrid(a,b,c,d,e,f,g,h,j);
v=(9*a) + (12.5*b) + (15*c) + (17*d) + (20*e) + (22.5*f) + (27*g) + (30*h) + (35*j) ;

Sign in to comment.

Answers (0)


Translated by