Matlab variable rounding issue
Mostrar comentarios más antiguos
I have a variable (B_WD) that is a 295x4 double, which I am plotting using quiver. It is wind direction vectors ploted over time along a line.
quiver (B_WD(:,1),B_WD(:,2),B_WD(:,3),B_WD(:,4), 'k');
Varibles before code runs.......(4 lines)
738226.7222 0.0000 -0.3000 -0.8000
738226.7292 0.0000 0.2000 -0.5000
738226.7361 0.0000 0.3000 -0.5000
738226.7431 0.0000 0.3000 -1.1000
The first column is the position on x-axis (I am plotting the arrows along a line -hence the zeros in column 2).
When I run the code the first column switches to less precision, rounding to 2dp and some arrows plot from the same start point
Variable after code runs......see rounding
738226.7200 0.0000 -0.3000 -0.8000
738226.7300 0.0000 0.2000 -0.5000
738226.7400 0.0000 0.3000 -0.5000
738226.7400 0.0000 0.3000 -1.1000
I have been reading the help and have tried changing the format of the variable to 'long', I have replaced numbers and re-saved, nothing seems to stop this.
Advice greatly appreciated
3 comentarios
format long
A = [738226.7222 0.0000 -0.3000 -0.8000
738226.7292 0.0000 0.2000 -0.5000
738226.7361 0.0000 0.3000 -0.5000
738226.7431 0.0000 0.3000 -1.1000 ]
I don't see any change...
Heather Purdie
el 21 de Jul. de 2022
Bruno Luong
el 21 de Jul. de 2022
Editada: Bruno Luong
el 21 de Jul. de 2022
"When I run the code the first column switches to less precision"
You should tel us what is the code. If you don't change/assign the variable it should remain identical.
Respuestas (1)
B_WD = [
738226.7222 0.0000 -0.3000 -0.8000
738226.7292 0.0000 0.2000 -0.5000
738226.7361 0.0000 0.3000 -0.5000
738226.7431 0.0000 0.3000 -1.1000 ];
quiver (B_WD(:,1),B_WD(:,2),B_WD(:,3),B_WD(:,4), 'k');
% The first column looks like datenum
datestr(B_WD(:, 1))
4 comentarios
Heather Purdie
el 22 de Jul. de 2022
Chunru
el 22 de Jul. de 2022
What is your data source? What is the format of data source?
Heather Purdie
el 22 de Jul. de 2022
Heather Purdie
el 22 de Jul. de 2022
Categorías
Más información sobre Annotations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
