Effacer les filtres
Effacer les filtres

How to add number of cells in a column and not the values in that cells?

1 vue (au cours des 30 derniers jours)
Gargi
Gargi le 5 Fév 2015
Commenté : Gargi le 8 Fév 2015
I have a file with single column and 365 rows. The file is attached with this. I have to check the data stored in each cell whether it is <=0 or not. If the data stored in cell is <=0, I have to count that total number of cells (not the addition of values in those cells) and store it in any variable. Kindly, help me regarding this.
Thanks & Regards

Réponse acceptée

Hikaru
Hikaru le 5 Fév 2015
V = xlsread('Book1.xlsx');
c = V <= 0; % check the condition
ans = sum (c) % count total number of cells
  2 commentaires
Gargi
Gargi le 6 Fév 2015
Thanku Sir....!!
Gargi
Gargi le 8 Fév 2015
Sir, one more query is there.....if I want to check only first thirty data whether it is greater <=0, and count the cells and again the next thirty, then how it will be done? I've prepared the program like this but not working, please help me
A=xlsread('tb.xls','sheet1'); i=1:365; %total number of rows j=1:1; % total number of column A(i,j)=1; % first cell of the sheet while (A(i,j)<=30) %no.of cells <=30 c = A(i,j) >= 0; % condition for checking data in each cell total = sum (c); % total number of cells A(i,j)=A(i,j)+30; % loop for the next 30 data end
Thanks & Regards

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by