Reverse 2D-lookup table: issues iterating through loops
21 visualizaciones (últimos 30 días)
Johanan Agarwal el 3 de Jul. de 2020
I am trying to implement a reverse 2d-lookup table as described in this thread:
The accepted answer provides this code for finding an input B1 at a specified A1 and C1 input:
A=[17.9 18.0 18.1 18.2]';
B=[0.4 0.5 0.6 0.7];
C=[67 89 95 108
74 92 110 123
80 97 115 127
84 106 119 135];
I am trying to do a similar thing with inputs p,d, trying to get output s which I have stored in the variable so
[P,S] = meshgrid(54020:100:101320,0:10:3000);
d = -100.*(((((1373.393./4.002602).*8.3144598).*300)./((P+S).*0.4569)).*((log(P./(P+S)))-(P./(P+S))+1));
so = zeros(301, 474);
p = 54020:100:101320;
p = p';
s = 0:10:3000;
for i = 1: size(p)
for j = 1:size(s) -1
I initialized the so variable as a matrix of zeros in the start to avoid a warning saying the size of so will be increasing throughout the iteration of the loops.
However, when running this code, so remains unpopulated and remains as a matrix of zeros
I am not sure why this is the case. Any help is much appreciated.
Jyotsna Talluri el 7 de Jul. de 2020
In your code provided, size of array s is [1 301].
for j = 1:size(s)-1 % first element of the size array is considered
In above line j is empty row vector due to which loop excecution does not take place and hence the array 'so' remains as it is initialized.
Try replacing your code with below lines.
for i = 1:length(p)
for j = 1:length(s)