python to matlab [1,x] form question

조회 수: 1 (최근 30일)
fima v
fima v 2020년 4월 13일
답변: Peng Li 2020년 4월 13일
Hello ,there is a trick in python to turn every matrices of NX2 into an NX2 matrices where the first column is all '1'
as shown in python bellow. i tried the same trick in matlab, its not working.
Where did i got wrong?
Thanks.
python:
feature_matrix = (feature_matrix - feature_matrix.mean()) / feature_matrix.std()
matlab:
x_data=[1:1000]
onss=ones(1,1000)
x_mat=[onss;x_data]'
x_mat=(x_mat-mean(x_mat))./std(x_mat);

답변 (1개)

Peng Li
Peng Li 2020년 4월 13일
why don't you zscore the x_mat first and add your column vector of all ones, although I don't quite understand why you want to do this. mathematically, std(ones(1, whateverLength)) is 0 and you divide 0 by 0 which will give you a nan.

카테고리

Help CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by