MATLAB: Change two variable in the name in a loop using eval or any other command

eval with variableevil eval

Hi I´m having a problem with this code:
HOw can I change both the M and N in the varibles of P_M_out_N names in a loop. Ithe following colud change N with loop
but I do not know how to change M values in the loop.
clc; clear all; close all
%P_M_out_N = u^j
u=3;
j=1:5;
M= [1 8 6 2 4];
N =[2 3 7 8 12]
for j = 1:length(M)
eval(sprintf('M_out_of_%d=u^j', N(j)))
end
%%
P_1_out_2 = u
P_8_out_3 = u^2
P_6_out_7= u^3
P_2_out_8 = u^4
P_4_out_12 = u^5

Best Answer

for k=1:numel(M)
s.(sprintf('P_%d_out_%d',M(k),N(k)))=u^k;
end