필터 지우기
필터 지우기

How can I make this matrix function?

조회 수: 2 (최근 30일)
minsoo kim
minsoo kim 2018년 2월 5일
답변: Harish Ramachandran 2018년 2월 8일
Let's say I have a matrix A[x,y,z]
If A[i,j,k]<N, (i<=x, j<=y, k<=z, N : certain value.)
then A[i,j,k]=0
else nothing happens.
I can make this function if I use "for" statement, but using "for" statement in matlab consumes a lot of time.
I'm sure there is a function that best fits what I want to do.
So, How can I make this function without using "for" statement?

답변 (1개)

Harish Ramachandran
Harish Ramachandran 2018년 2월 8일
This is an example of your use case on a 2-D matrix. The same is scalable for a 3-D matrix.
X = rand(5)
X =
0.7577 0.7060 0.8235 0.4387 0.4898
0.7431 0.0318 0.6948 0.3816 0.4456
0.3922 0.2769 0.3171 0.7655 0.6463
0.6555 0.0462 0.9502 0.7952 0.7094
0.1712 0.0971 0.0344 0.1869 0.7547
X(X<0.5) = 0;
X =
0.7577 0.7060 0.8235 0 0
0.7431 0 0.6948 0 0
0 0 0 0.7655 0.6463
0.6555 0 0.9502 0.7952 0.7094
0 0 0 0 0.7547

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!