Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
How can I fetch values from 2 vectors of numbers without without changing their format.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I am asking for a matrix to return values from 2 vectors: one is the company id (a number), the other one is the return according to the CAPM. Since the company number is quite high (7900,9800 a.s.o.) and the return is low (0.02,0.05,0.07) Matlab seems to standardie them when putting them together. It returns 0.0790, 0.9800 for companies and 0.0000 0.000 for returns. How can I avoid this standardization problem? When I transform The company to string, it returns the same value 32,000 for the whole column besides the last 3 rows, where it retuns 49.000. How can I solve it?
0 Kommentare
Antworten (2)
Jacob Halbrooks
am 11 Mär. 2014
You can control how MATLAB displays your data using FORMAT. This is independent of how MATLAB actually stores and handles your data. From the help for FORMAT:
format does not affect how MATLAB computations are done. Computations
on float variables, namely single or double, are done in appropriate
floating point precision, no matter how those variables are displayed.
In the default short format, a matrix with large and small numbers can obscure the small numbers:
>> [7900, 9800; 0.02, 0.05]
ans =
1.0e+03 *
7.9000 9.8000
0.0000 0.0001
Try using one of the other formats. For example:
>> format shorte
>> [7900, 9800; 0.02, 0.05]
ans =
7.9000e+03 9.8000e+03
2.0000e-02 5.0000e-02
1 Kommentar
Sagar Damle
am 11 Mär. 2014
a = [7900, 9800; 0.02, 0.05]
fprintf('%d \t\t %g\n',a);
Try this! See help about 'fprintf()' in MATLAB help.
0 Kommentare
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!