round off problem in matlab
이전 댓글 표시
I have 4 variables each have 4 values (1x4) in it and I want to store all in value in 1 variable (4x4) but values are change when i do it.
MAV = [0.0924317411754942 0.0313003411430704 0.00365072354007141 0.00332056432198707]
waveLen = [172.697769103870 68.7603283596702 69.2536410243476 63.2141284111186]
zcdOut = [560 719 6155 6260]
slope_count = [478 212 4949 4830]
HG0_extracted_feature = [waveLen; MAV; zcdOut; slope_count]
it gives
173 69 69 63
0 0 0 0
560 719 6155 6260
478 212 4949 4830
note MAV values become zero, it round off waveLen, etc values...
how i correct it?
Thank you
채택된 답변
추가 답변 (2개)
Raj
2019년 9월 19일
Just add 'format longg' before your code like this:
format longg
MAV = [0.0924317411754942 0.0313003411430704 0.00365072354007141 0.00332056432198707]
waveLen = [172.697769103870 68.7603283596702 69.2536410243476 63.2141284111186]
zcdOut = [560 719 6155 6260]
slope_count = [478 212 4949 4830]
HG0_extracted_feature = [waveLen; MAV; zcdOut; slope_count]
Read about format here:
The values are not changed. They are just displayed to the screen to 4 decimal points. Use format long to see more precision. Also, note that all elements are premultiplied by 1000.

댓글 수: 3
Ali Asghar
2019년 9월 20일
Matt J
2019년 9월 20일
As Steven. mentioned, that is probably because one of the vectors you are merging is uint8 or similar.
Steven Lord
2019년 9월 20일
Rows 3 and 4 of the resulting array have values too large for uint8 or int8 so they would need to be at least 16-bit integers.
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!