3 views (last 30 days)

Hi Folks,

This loop code is working fine but I would like to simplify it further. Can anyone help?

Basically, i need syntax to automate the row definitions of k, SE_ans and A, the columns are fine I think.

k is a 3*3 matrix, SE_ans is a 3*1 vector, A is a 3*3 identify matrix. The rests are just constants.

for i=1:size(k,1)

k(1,i)=subs(SE_ans(1,:),[theta_1, theta_2, theta_3, k_t1,k_t2,k_t3],[A(i,1), A(i,2), A(i,3),1,2,3])

k(1,i)=subs(SE_ans(1,:),[theta_1, theta_2, theta_3, k_t1,k_t2,k_t3],[A(i,1), A(i,2), A(i,3),1,2,3])

k(1,i)=subs(SE_ans(1,:),[theta_1, theta_2, theta_3, k_t1,k_t2,k_t3],[A(i,1), A(i,2), A(i,3),1,2,3])

k(2,i)=subs(SE_ans(2,:),[theta_1, theta_2, theta_3, k_t1,k_t2,k_t3],[A(i,1), A(i,2), A(i,3),1,2,3])

k(2,i)=subs(SE_ans(2,:),[theta_1, theta_2, theta_3, k_t1,k_t2,k_t3],[A(i,1), A(i,2), A(i,3),1,2,3])

k(2,i)=subs(SE_ans(2,:),[theta_1, theta_2, theta_3, k_t1,k_t2,k_t3],[A(i,1), A(i,2), A(i,3),1,2,3])

k(3,i)=subs(SE_ans(3,:),[theta_1, theta_2, theta_3, k_t1,k_t2,k_t3],[A(i,1), A(i,2), A(i,3),1,2,3])

k(3,i)=subs(SE_ans(3,:),[theta_1, theta_2, theta_3, k_t1,k_t2,k_t3],[A(i,1), A(i,2), A(i,3),1,2,3])

k(3,i)=subs(SE_ans(3,:),[theta_1, theta_2, theta_3, k_t1,k_t2,k_t3],[A(i,1), A(i,2), A(i,3),1,2,3])

end

thanks

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 1 Comment

## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/180389-simplify-matlab-for-if-statements-further#comment_268523

⋮## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/180389-simplify-matlab-for-if-statements-further#comment_268523

Sign in to comment.