matrix multiplication of any 2 matrix in which a matrix contains a variable term suppose m=0:0.1:5.....how to do this multiplication for each value of m by creating a loop.....

matrix multiplication of any 2 matrix in which a matrix contains a variable term suppose m=0:0.1:5

1 Comment

this are the 2 matrixs
F=[1-2cos(alpha1)+2cos(alpha2)-2cos(alpha3)-(pi/4)*m;
1-2cos(5*alpha1)+2cos(5*alpha2)-2cos(5*alpha3);
1-2cos(7*alpha1)+2cos(7*alpha2)-2cos(7*alpha3)]
K=[2sin(alpha1) -2sin(alpha2) 2sin(alpha3);
10sin(5*alpha1) -10sin(5*alpha2) 10sin(5*alpha3);
14sin(7*alpha1) -14sin(7*alpha2) 14sin(7*alpha3)]
note alpha1,alpha2,alpha3 can be any value...

Sign in to comment.

Answers (1)

Ujjwal - please describe how you are multiplying the above two matrices. Is it
K*F
or something else? If m is a variable, then you would want to initialize m before you do the matrix multiplication. Something like
mValues=0:0.1:5;
results = zeros(3,1,length(mValues));
for k=1:length(mValues)
m = mValues(k);
F=[1-2*cos(alpha1)+2*cos(alpha2)-2*cos(alpha3)-(pi/4)*m;
1-2*cos(5*alpha1)+2*cos(5*alpha2)-2*cos(5*alpha3);
1-2*cos(7*alpha1)+2*cos(7*alpha2)-2*cos(7*alpha3)];
K=[2*sin(alpha1) -2*sin(alpha2) 2*sin(alpha3);
10*sin(5*alpha1) -10*sin(5*alpha2) 10*sin(5*alpha3);
14*sin(7*alpha1) -14*sin(7*alpha2) 14*sin(7*alpha3)];
results(:,:,k) = K*F;
end

Categories

Asked:

on 2 Aug 2015

Commented:

on 3 Aug 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!