problem with tbl,xvar,yvar form of plot()
이전 댓글 표시
Greetings, as per title i have a problem with tbl,xvar,yvar form of plot().
I have an array with history of the evolution of the parameters of a function during parameter optimization.
num_iterations = size(param_history, 1);
num_chains = size(param_history, 2);
num_dimensions = size(param_history, 3);
param_at_step = zeros(num_iterations, num_chains * num_dimensions);
The array is of the form 10000x8 - 10k iterations by 2 parameters for each of the 4 independent optimization chains. I expected:
for iteration = 1 : num_iterations
for chain_id = 1 : num_chains
for param = 1 : num_dimensions
column = ((chain_id-1) * 2) + param;
param_at_step(iteration, column) = param_history(iteration, chain_id, param);
end
end
end
plot( param_at_step, [1 3 5 7], [2 4 6 8] );
to plot the evolution of the parameters in the parameter space, but i get an error:
Error using plot
Specify the coordinates as vectors or matrices of the same size, or as a vector and a matrix that share the same length in at least one dimension.
I am confused, what am I doing wrong?
댓글 수: 1
The code involving three nested for loops for constructing param_at_step from param_history
param_history = randn(10000,4,2); % random data
num_iterations = size(param_history, 1);
num_chains = size(param_history, 2);
num_dimensions = size(param_history, 3);
param_at_step = zeros(num_iterations, num_chains * num_dimensions);
for iteration = 1 : num_iterations
for chain_id = 1 : num_chains
for param = 1 : num_dimensions
column = ((chain_id-1) * 2) + param;
param_at_step(iteration, column) = param_history(iteration, chain_id, param);
end
end
end
num_iterations = size(param_history, 1);
param_at_step_test = reshape(permute(param_history,[1 3 2]),num_iterations,[]);
And the result is the same:
isequal(param_at_step_test,param_at_step)
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Vehicle Dynamics Blockset에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


