The parameter 'Y' must be a real-valued vector with length same as the columns of 'X'.

조회 수: 7 (최근 30일)
Peter_SG
Peter_SG 2018년 6월 9일
답변: Peter_SG 2018년 6월 10일
I have a 447x10 matrix, which I subdivided into a 447x1 vector of an Y-response variable and a 447-9 vector of a X-predictor variables. I get the above error when I try:
[B,FitInfo] = lasso(Y,X);
Using n = length(Y) yields the same length for Y and X, while
tf = isreal(Y) and
tf = isreal(X)
both return 1, which means both Y and X are real-valued vectors with the same length. Anything I overlooked? Thanks
  댓글 수: 2
dpb
dpb 2018년 6월 9일
편집: dpb 2018년 6월 9일
Show, don't just tell :)
"which means both Y and X are real-valued vectors..."
Not precisely, no. Means neither contain an imaginary part but says nothing about shape.
You keep using "vector", but X needs to be an array.
What does
whos Y X
return?

댓글을 달려면 로그인하십시오.

답변 (1개)

Peter_SG
Peter_SG 2018년 6월 10일
Thank you very much for all your replies - I had indeed had the wrong order. Thanks and apologies!

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by