The logical indices contain a true value outside of the array bounds
Ältere Kommentare anzeigen
Please, how can I tackle "The logical indices contain a true value outside of the array bounds" error? I don't what exactly is the cause.
load('sol_active_flow_varinying_xiL.mat')
xi=xivals;
L =Lvals;
intabsul = intabsul;
intabsur =intabsur;
absintul =absintul;
absintur =absintur;
%% This is where I having an issue
test1 = intabsul == absintul & intabsur == absintur;
subset_xi_1 = xivals(test1);
subset_Lv_1 = Lvals(test1);
test2 = intabsul ~= absintul & intabsur ~= absintur;
subset_xi_2 = xivals(test2);
subset_Lv_2 = Lvals(test2);
%
test3 = intabsul ==absintul & intabsur ~= absintur;
subset_xi_3 = xivals(test3);
subset_Lv_3 = Lvals(test3);
%
test4 = intabsul ~= absintul & intabsur == absintur;
subset_xi_4 = xivals(test4);
subset_Lv_4 = Lvals(test4);
6 Kommentare
jessupj
am 16 Feb. 2024
look at sizes of things.... your intabsul and other vars are 20x20 matrices, but xivals is a 20-lenght vector. that's why it gives you that error at xivals( some logical function of intabsul)
It' means you're trying to assign test1 a value e.g.
xivals(11,20)
that doesn't exist
"I don't what exactly is the cause."
The cause is very simple: you are trying to access an array element that does not exist. For example:
V = 1:3
V([false,false,true,false]) % okay
V([false,false,false,true]) % error: does element (1,4) exist? (hint: no)
Now take a close look at the sizes of your arrays.
University
am 16 Feb. 2024
Fangjun Jiang
am 16 Feb. 2024
This is the exact same question you asked previously. The cause of the problem has been clearly explained with a simple example. You have your data and you can run your code line by line, observe the value of the variable and see what is not expected and figure out a solution.
Without comments and with those confusing variable names, it's really hard to try to understand what the program tries to achieve. If you want help, you have to explain to an extent that others can understand.
University
am 16 Feb. 2024
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Whos finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
