2つの値の違いがわからない
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
yuta
el 5 de Jul. de 2022
Comentada: yuta
el 9 de Jul. de 2022
Aとstartの中身が私には同じに見えますが、同様の処理をしても結果が異なります。
なぜこのような違いが生じるのかご教示いただければ幸いです。
load('A.mat')
A
load('start.mat')
start
load('B.mat')
C = find(B == A(1));
C
D = find(B == start(1));
D
0 comentarios
Respuesta aceptada
Kojiro Saito
el 5 de Jul. de 2022
出力の表示形式で値が丸め込まれて見えているのが原因です。
こちらのドキュメントに詳細がありますが、MATLABではデフォルトでshortの表示形式なので、小数点以下が4桁の固定小数点形式で表示されます。
実はA(1)とstart(1)では同じ値になっていません(A(1) == start(1)がfalseの0になります)。
load('A.mat')
A(1)
load('start.mat')
start(1)
A(1) == start(1)
桁数を増やして表示すると、A(1)とstart(1)で値が違っているのが確認できます。
format long
A(1)
start(1)
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!