Matrix dimensions must be agree

7 vues (au cours des 30 derniers jours)
N/A
N/A le 18 Juil 2018
Réponse apportée : Adam le 18 Juil 2018
Hello. I have a error about matrix dimensions and below is the code
clear all
n = 1100;
x = [randn(300, 1);
randn(500, 1)+8.0;
randn(300, 1)+12.0];
m = 3;
mu = linspace(min(x), max(x), m)';
tmp1 = (repmat(x, [m 1]) - repmat(mu, [1 n])).^2;
I have no idea about why this error is occurred because the size of matrix must be same. The error occurs in the final line.(tmp1=blah) How to fix it?

Réponse acceptée

Adam
Adam le 18 Juil 2018
size( repmat(x, [m 1]) )
size( repmat(mu, [1 n]) )
on the command line will quickly show you the problem. The first is 3300 x 1, the second is 3 x 1100

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