MATLAB: Loaded variable can’t be indexed, unrecognized function or variable error

indexingloadMATLAB

I am attempting to pull a specific index from data loaded into a file. Here's the code in question:
load 'aes_power_data.mat';
n_traces = 200;
traces = traces (1:n_traces, :);
plaintext = plain_text (1:n_traces, :);
...
function [result] = predict_Sbox(key, p_Text, byte)
PT = plaintext(p_Text, byte);
pos = bitxor(key,PT);
result = sbox(pos);
end
Load places a 200×16 double into the workspace, but the line "PT = plaintext(p_Text, byte);" is when the error occurs. So the first time I call this, it should pull the first value from plaintext (1,16). What am I doing incorrectly? Is the error in catching the variable or in my use of function or something else?

Best Answer

You do not have a nested function with shared variables, and you do not pass plaintext to the function.