How to convert the values greater than one to less than one for a matrix stored in workspace

1 ビュー (過去 30 日間)
jaah navi
jaah navi 2021 年 6 月 19 日
回答済み: Star Strider 2021 年 6 月 19 日
I am having a matrix size (300x2000) stored in workspace.
In that some of the values are greater than 1 for example (1.345, 1.678, 2.345, 3.456, 4.456,....)
I want to changes those values to ( 0.345, 0.678, 0.345,0.456,....)
Could anyone help me how to change those values .

回答 (2 件)

Stephen
Stephen 2021 年 6 月 19 日
M = [1.345, 1.678, 2.345, 3.456, 4.456]
M = 1×5
1.3450 1.6780 2.3450 3.4560 4.4560
M = mod(M,1)
M = 1×5
0.3450 0.6780 0.3450 0.4560 0.4560

Star Strider
Star Strider 2021 年 6 月 19 日
Use rem or mod
v = [1.345, 1.678, 2.345, 3.456, 4.456 0.123 0.456];
vnew = rem(v,1)
vnew = 1×7
0.3450 0.6780 0.3450 0.4560 0.4560 0.1230 0.4560
Using either with the second argument being 1 produces the fractional part of decimal fractions. (I added two others less than 1 to demonstrate that it does not affect them.)
.

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by