Unable to multiply a matrix in loop with a matrix without loop?
Mostra commenti meno recenti
Unable to execute u * q , where q and p are matrices of hermite polynomials. kindly help me..
clc; clear all
%
format rat
syms t
M = [0 2 0 0; 0 0 4 0; 0 0 0 6; 0 0 0 0];
u = [0 0 0 0; 0 1/12 0 0; 0 0 1/6 0; 0 0 0 1/4];
%
for t =[0 1/3 2/3 1]
p= hermiteH(0:3, t);
q= hermiteH(0:3, t/2);
disp ( p*M- u * q )
end
Risposte (1)
KSSV
il 3 Apr 2017
You see your matrices are not obeying rule of matrix multiplication. The below works according to the dimensions of matrices.
format rat
syms t
M = [0 2 0 0; 0 0 4 0; 0 0 0 6; 0 0 0 0];
u = [0 0 0 0; 0 1/12 0 0; 0 0 1/6 0; 0 0 0 1/4];
%
for t =[0 1/3 2/3 1]
p= hermiteH(0:3, t);
q= hermiteH(0:3, t/2);
disp ( p*M- (u * q')' )
end
Categorie
Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!