Hello everyone,
I am trying to populate matrix elements so that I can take its determinant.
n=2;r = [];for (i=1:n) t = sym(['r' int2str(i)]); r = [r; t];endv=cell(n,1);for i=1:n v{i}=zeros(n,n);endv{1}(1,1)=r(1)-1; -------->ERROR!v{1}(2,1)=r(2)-1;v{2}(1,1)=r(1)-1;v{2}(2,1)=r(2)-1;for i=1:n for j=1:n %v{i}(j,1)=v(j)-1;
for k=2:n v{i}(j,k)=p{i}(k,j)-p{i}(1,j); end endend%above code should replace the below to allow for any values of n. The below code works fine.
v{1}=[v(1)-1,p{1}(2,1)-p{1}(1,1);v(2)-1,p{1}(2,2)-p{1}(1,2)];v{2}=[v(1)-1,p{2}(2,1)-p{2}(1,1);v(2)-1,p{2}(2,2)-p{2}(1,2)];%compute determinant
v_det=cell(n,1);for i=1:n v_det{i}=det(v{i});endError given is:??? The following error occurred converting from sym to double:Error using ==> mupadmexError in MuPAD command: DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use the VPA function instead.
help please!! I tried using the vpa function as suggested with no success.
Best Answer