필터 지우기
필터 지우기

Error finding matrix indices where elements obey a condition

조회 수: 1 (최근 30일)
ferda sonmez
ferda sonmez 2019년 3월 22일
댓글: Luna 2019년 3월 28일
Hi,
I have a (30,1) matrix A filled with both positive and negative double values with high precisions.
I do the B= A>0 expecting a resulting matrix filled with 0s and 1s based on the value of original matrix such as
[0,
0,
1,
1,
0,
....]
However, when I display I get a matrix like below
0.0 < -60.80089912054130723383673691361028456512560544254638307756720395046146077078219605027697980403900146484375
0.0 < -40.47441497086561319883182687840919573785507473004455923328153712191512791918057700968347489833831787109375
0.0 < 11.9150901590727927897158716535914255438713276913571208738565018227240077663964257226325571537017822265625
0.0 < 50.24337655630030618369864852262179095255359883940103235308691394245261818696235422976315021514892578125
0.0 < -12.788094842081277874683606597932106962408104528383932295293478643982698628178695798851549625396728515625
0.0 < -19.7994345791724984686511623375698392780606832842132285447736268595153585891921466100029647350311279296875
0.0 < 44.20960440529531749044620672799080999950637846265719961065220598196712220584458918892778456211090087890625
0.0 < -38.4752715808701180299125340913012275096601820744906678455217984013980725421788520179688930511474609375
0.0 < -57.1261686699021779161260124218737353314343618323505877827184033790341999292650143615901470184326171875
0.0 < -15.50675798085333259859508957067109961395543474125240585269404109021451620975540208746679127216339111328125 0
Later when use matrix B in a matrix multiplication I get a lot of NaN values. Where am I doing wrong? I will be very appreciated if I can find a solution dfor this . Cause I am struggling due to this issue for a few days..
Best Regards,
Ferda
  댓글 수: 7
madhan ravi
madhan ravi 2019년 3월 22일
When you use vpa() or vpasolve() the class of the variable becomes symbolic.
Luna
Luna 2019년 3월 25일
Ah now I understand, thx :)

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

채택된 답변

Luna
Luna 2019년 3월 22일
Hi Ferda,
Please see my comments below:
% first convert it to double array:
A = double(input_of_hidden_layer2);
% indexing your conditions:
B = A > 0;
% get the values which are greater than zero from that index:
A(B)

추가 답변 (1개)

Walter Roberson
Walter Roberson 2019년 3월 23일
B = isAlways(A>0);
will give you a logical result. Or you could
B = logical(A>0);

카테고리

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

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by