简体   繁体   English

无法在 matlab 中乘以矩阵

[英]unable to multiply matrix in matlab

Good day!再会!

I am trying to multiply two matrices those are:我正在尝试将两个矩阵相乘:

z = [64 x 1]; z = [64 x 1]; with complex attribute.具有复杂属性。

top = [32 x 64]顶部 = [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两个矩阵 class 都是双倍的,但是当我尝试运行程序时,我在最后一行出现错误

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]我想要的 output 是 [32 x 1]

You seem to have the product y = z * top where size(z) == [64, 1] and size(top) == [32, 64] .您似乎有产品y = z * top where size(z) == [64, 1]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 ).这两个矩阵的大小不适合按此顺序相乘,因为“内部”尺寸必须一致,但在您的情况下1 ~= 32 (请参阅https://en.wikipedia.org/wiki/Matrix_multiplication#Definition ) . What you probably want is你可能想要的是

y = top * z

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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