简体   繁体   中英

unable to multiply matrix in matlab

Good day!

I am trying to multiply two matrices those are:

z = [64 x 1]; with complex attribute.

top = [32 x 64]

both of the matrices class are double but when I tried to run the program I got an error at the last line

Matrix dimensions must agree.

here is the code:

clear all; clc;
load('eeg.mat'); 

load('top.mat');

N = 64;
M = 32;


Psi = dftmtx(N);
z = Psi * VarName1;
y = z * top;

the output that I want is [32 x 1]

You seem to have the product y = z * top where size(z) == [64, 1] and size(top) == [32, 64] . The sizes of these two matrices are incompatible to be multiplied in this order, as the "inner" dimensions must agree, but in your case 1 ~= 32 (see https://en.wikipedia.org/wiki/Matrix_multiplication#Definition ). What you probably want is

y = top * z

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM