Making .txt file into use????
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
So Im given a .txt file which consists of number 1 to 10 with decimals and now im asked to make a table(sort of) for number between 9 to 10 and the counts of it then number 8 to 9 and so on. using logical operational and relational operators. How im suppose to link both of them??
2 Commenti
Geoff Hayes
il 29 Mar 2015
Victor - is this homework? Please clarify what you are expected to do with an example.
Risposte (1)
Star Strider
il 29 Mar 2015
This is one approach:
x = randi(1000, 1, 100)/100;
for k1 = 1:10
interval = [x > (k1-1) & (x <= k1)];
interval_sum(k1) = sum(interval);
end
% COMPARE WITH ‘histc’
binrng = [0:10];
hcounts = histc(x, binrng);
I will leave it to you to import your text file and change the code I posted to meet your requirements. (The comparison with the histc function is informational only to check the performance of the loop. It is not part of the code.)
0 Commenti
Vedere anche
Categorie
Scopri di più su Annotations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!