Why my var6 appear divide by 1000?

8 vues (au cours des 30 derniers jours)
Tony Castillo
Tony Castillo le 6 Oct 2016
Commenté : dpb le 10 Oct 2016
Hi, everyone i'm preparing a script for solve several things, among those the kmean, but i have noted that vector called "var6" appear divided by 1000, when i write in the command windows "disp(Var6)", but distinctly, the other five variables when i "disp" each one appear or are printed correctly as it are in spreedsheet of excel, can you help me to detect why var6 is divided by 1000?.
Finally, i need to detect the "hour" of each one of my 7 cluster, how can i do that?, for locate the tipical behaviour in every one of my 7 cluster of data.
Thanks in advance.

Réponse acceptée

dpb
dpb le 6 Oct 2016
You've not showed use the display in question, but more than likely it's simply the Matlab logic to display widely disparate values in an array in a succinct fashion. The internal values (as shown by looking at the individual values as you've done) are not affected; it's only a display artifact.
Example, since we can't see yours specifically--
>> x=[pi*10^6 1];
>> disp(x)
1.0e+06 *
3.1416 0.0000
>> x(1)
ans =
3.1416e+06
>> x(2)
ans =
1
>>
That look similar to your problem? If you have need for a specific format, write the results specifically--
>> fprintf('%.2f %d\n',x)
3141592.65 1
>>
As for the other question, I've no klew what you're asking; can you explain further w/ and example, maybe?
  2 commentaires
Tony Castillo
Tony Castillo le 10 Oct 2016
Thanks for the explanation given above. My second question is how to determine the numbers of elements in every cluster?. Goodbye.
dpb
dpb le 10 Oct 2016
Again, not enough context/explanation to understand what you're asking, sorry. What's a "cluster"? The above variables (and, btw, writing a number of variables Var1, Var2, Var3, Var4, Var5, etc., is likely not a very good choice; it means either rewriting a new line of code for every operation (or an operation so ugly and error-prone I'm not even going to mention it here in case doing so might tempt you to try it). Use arrays or cell arrays or one of the other higher abstractions to hold the data and then you'll be able to manipulate it in a much simpler fashion.
If it is these that you mean, then
numel(Var1) % might be what you're looking for

Connectez-vous pour commenter.

Plus de réponses (1)

Steven Lord
Steven Lord le 6 Oct 2016
When you execute this code, does it look like what happens when your var6 variable is divided by 1000?
format
x = [1234.5 1234.56];
If so that's due to the display format. Above the two numbers in x that look like they've been divided by 1000 you should see something like "1.0e+03 * " -- that's the factor of 1000 that your believe is missing. If you change the display format to something else, like format shortg or format longg, the results may look close to what you expect. Note that changing the format DOES NOT change the actual values stored in the variable. It only changes how those values are displayed on the screen (or in a diary file or log file created by the -logfile startup option.)
format shortg
x = [1234.5 1234.56]
format longg
x = [1234.5 1234.56]
  2 commentaires
Tony Castillo
Tony Castillo le 10 Oct 2016
Thanks, i can understand what you mean about my question, but i don't understand yet, why matlab only does it for a unique group of var, the Var6, and not for all the groups Var1, Var2, Var3, Var4, Var5.
Steven Lord
Steven Lord le 10 Oct 2016
The values in your other variables are either integer values or are small enough that they can be written in "Scaled fixed point format with 5 digits." without needing the factor to be extracted.
format
x = 12345678 % integer value
x = 1.23 % small enough

Connectez-vous pour commenter.

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by