Dear MATLAB Users,
I am trying to fill in the empty array using a recursive formula. The formula is shown as follows:
(This expression is the base case for resursive function)
For all
In this formula, I already know the B array which is .
So far, I had many attempts but non of them worked. My function is shown below. When I run it, I get the error message "Assignment has more non-singleton rhs dimensions than non-singleton subscripts". Could you please help me to solve this problem?
function I_matrix = fill_I_recursively(B_matrix, u_ind, v_ind, w_ind)M = size(B_matrix,1);if u_ind == 1 && v_ind == 1 && w_ind == 1 I_matrix(u_ind,v_ind,w_ind) = 0; else if w_ind > 1 I_matrix(u_ind,v_ind,w_ind) = fill_I_recursively(B_matrix, u_ind, v_ind, w_ind-1) + B_matrix(u_ind,v_ind,w_ind-1); elseif v_ind > 1 I_matrix(u_ind,v_ind,w_ind) = fill_I_recursively(B_matrix, u_ind, v_ind-1, M-1) + B_matrix(u_ind,v_ind-1,M-1); else I_matrix(u_ind,v_ind,w_ind) = fill_I_recursively(B_matrix, u_ind-1, M-1, M-1) + B_matrix(u_ind-1,M-1,M-1); endend
I am looking forward to hearing from you
Best Answer