Data reading/Filtering, Excel>>Array

조회 수: 2 (최근 30일)
Hello kity
Hello kity 2012년 12월 11일
Hi,
I have an excel file with data.
an example
colom1:
1
2
3
4
5
empty
empty
6
7
8
9
10
empty
empty
What I want to do is this:
  • get every number above the first empty cell (in example the number 5 and 10)
  • then calculate, 5 - 1 , 5 -2 , 5-3 ,5-4
same for the next set of data (10-6 10-7 10-8 10-9), this for the entire colom.
With xlsread I read the file, then select the colom with num(:,x). I get an arraw with numbers then 2 Nanns between each set of data....
what then to do...

답변 (2개)

Vishal Rane
Vishal Rane 2012년 12월 11일
Use isnan and find functions.
Your data read from excel is something like :
a = [ 1 2 3 4 5 NaN NaN 6 7 8 9 10 NaN NaN 11 12]
find(isnan(a))
will give you the locations of all NaN in the array.
  댓글 수: 1
Vishal Rane
Vishal Rane 2012년 12월 11일
Use the NaN locations to further build your logic

댓글을 달려면 로그인하십시오.


Hello kity
Hello kity 2012년 12월 11일
편집: Hello kity 2012년 12월 11일
I used isnan and find. That gives me a new array with all the locations of the isnans.
for example
1 2 3 4 5 NaN NAn
I get 6 and 7 as NaN... but how can I say if you find the 6th as NaN then use the 5th to calculate, 5-1 and 5-2 etc..
thank you

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by