Hi, all
I do have a function running within some loops and create variables with dynamically generated names based on the values of the loops.
The result of my function is a 1000 x 50 matrix of integers. I want to plot the mean of each collumn. Therefore, here's the code
% Distribuição de espécies em grupos
for tipoQSG = tipoQSGmin:tipoQSGmax for gradienteQSG = gradienteQSGmin:gradienteQSGmax% Interações interespecíficas
for tipoSIS = tipoSISmin:tipoSISmax for quantidadeSIS = quantidadeSISmin:quantidadeSISmax for concentracaoSIS = concentracaoSISmin:concentracaoSISmax for sinaisSIS = sinaisSISmin:sinaisSISmax for aleatorizacaoSIS = aleatorizacaoSISmin:aleatorizacaoSISmax% Efeito de grupos funcionais
for tipoSEG = tipoSEGmin:tipoSEGmax for sinalSEG = sinalSEGmin:sinalSEGmaxMPDF = myfunc(tipoQSG, gradienteQSG, tipoSIS, quantidadeSIS, concentracaoSIS, sinaisSIS, aleatorizacaoSIS, tipoSEG, sinalSEG)
end end end end end end end end end
I have no problems doing what I need if I type manually, for instance:
plot(mean(MPDF_111111111))
However, when I try to do it in a dynamic way, it fails.
% Distribuição de espécies em gruposfor tipoQSG = tipoQSGmin:tipoQSGmax for gradienteQSG = gradienteQSGmin:gradienteQSGmax% Interações interespecíficasfor tipoSIS = tipoSISmin:tipoSISmax for quantidadeSIS = quantidadeSISmin:quantidadeSISmax for concentracaoSIS = concentracaoSISmin:concentracaoSISmax for sinaisSIS = sinaisSISmin:sinaisSISmax for aleatorizacaoSIS = aleatorizacaoSISmin:aleatorizacaoSISmax% Efeito de grupos funcionaisfor tipoSEG = tipoSEGmin:tipoSEGmax for sinalSEG = sinalSEGmin:sinalSEGmax % Checa-se a execução satisfatória do cenário adotado anteriormente. Se
% ele já tiver sido executado em número suficiente de vezes,
% ignora-se-o e passa-se ao próximo.
% Checa se os resultados existem.
% dynamical plot attempt eval(['plot(' 'mean(' 'sprintf(''MPDF_%d%d%d%d%d%d%d%d%d'', tipoQSG, gradienteQSG, tipoSIS, quantidadeSIS, concentracaoSIS, sinaisSIS, aleatorizacaoSIS, tipoSEG, sinalSEG)' ')' ')' ])
% manual plot attempt
plot(genvarname(sprintf('MPDF_%d%d%d%d%d%d%d%d%d', tipoQSG, gradienteQSG, tipoSIS, quantidadeSIS, concentracaoSIS, sinaisSIS, aleatorizacaoSIS, tipoSEG, sinalSEG))) hold on % Try to see if the variable name might be wrong
eval(['sprintf(''MPDF_%d%d%d%d%d%d%d%d%d'', tipoQSG, gradienteQSG, tipoSIS, quantidadeSIS, concentracaoSIS, sinaisSIS, aleatorizacaoSIS, tipoSEG, sinalSEG)' ]) == MPDF_111111111 endend end end end endend endend
Why does it returns me a vector for the mean(MPDF_111111111), but a single value for the for the eval equivalent? How can I remedy this problem?
Thanks!
Best Answer