简体   繁体   中英

Error: operator *: nonconformant arguments (op1 is rxc, op2 is rxc )

I have implemented the following function to estimate Parzen Density of a matrix ,

parzen.m

function [retval] = parzen (matrix, dataPoint, variance)
    [r c] = size(matrix);
    A = ones(r, c)*dataPoint;
    sub = matrix - A;
    up = sub.^2;
    dw = 2 * variance;
    firstPart = 1/(sqrt(2*pi*variance));
    retval = firstPart * exp((-1)*(up/dw));

Error

>> parzen(train, test, 0.25)
error: parzen: operator *: nonconformant arguments (op1 is 1824x8, op2 is 1824x8
)
error: called from
    parzen at line 3 column 4
>>

How can I get rid of this error?

@ Benoit_11的commenet解决了我的问题。

A = ones(r,c) .* dataPoint.

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