Matrix multiplication. Trying to get scalar solution

1 vue (au cours des 30 derniers jours)
Joshua Tsui
Joshua Tsui le 10 Mai 2021
Commenté : Joshua Tsui le 10 Mai 2021
I am expecting a scalar value of 4/3 as the value for coor but am getting [2 0; 0 1]
Inputs as follows:
Number of floors: 2
Mass:2
Mass:1
numFlr=input('Number of floors: ');
nMode=[0.5 1]
nMode-nMode'
u0=ones(numFlr,1)
udot0=zeros(numFlr,1)
MVal=zeros(numFlr,1);
for i=1:numFlr
MVal(i)=input('Mass:');
end
M=diag(MVal);
% Choose=input('Mode: ');
% nMode=EigVec(:,Choose);
nModeT=nMode'
top=nMode.*M.*u0
bot=nMode.*M.*nModeT
coor=top/bot
The problem I am attemping is:

Réponse acceptée

James Tursa
James Tursa le 10 Mai 2021
Those should be matrix multiples, not element-wise multiplies. Remove the dots. E.g.,
top=nMode * M * u0;
bot=nMode * M * nModeT;

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by