Thread Subject: find function not reporting all column values

Subject: find function not reporting all column values

From: Valerie

Date: 9 Nov, 2009 02:01:05

Message: 1 of 2

Hi,

I have two datasets: one on elevation and one on tidal height and want to create a matrix that will give a value of 1 for when the tidal height exceeds elevation and a 0 for when the tidal height is less than or equal to the elevation. I had a colleague help me to write a script and it works when I run it on two of my datasets, but when I run it on my other datasets, I seem to be missing some values. For example, one of my elevation datasets has 441 entries and my tidal series is 11090 entries. When I run my script however, instead of getting something that's 441x11090, I get something that is 359X11090 and I'm not sure where the other 82 rows have disappeared to. I've pasted in the script I'm using below. Any suggestions on what might be causing the problem or suggestions for solutions would be greatly appreciated. Thanks.

load Mugu_1_Elevations.txt
load Mugu_M1_0_11012009.txt
date=Mugu_M1_0_11012009(:,1);
ht=Mugu_M1_0_11012009(:,7);
elev=Mugu_1_Elevations(:,4);
elev_Mugu=zeros(length(elev),length(date));
for
i=1:1:length(date)
ind=find(elev<ht(i));
inun_Mugu1(ind,i)=1;
end

Subject: find function not reporting all column values

From: TideMan

Date: 9 Nov, 2009 03:22:59

Message: 2 of 2

On Nov 9, 3:01 pm, "Valerie " <valerie.a.c...@gmail.com> wrote:
> Hi,
>
> I have two datasets: one on elevation and one on tidal height and want to create a matrix that will give a value of 1 for when the tidal height exceeds elevation and a 0 for when the tidal height is less than or equal to the elevation.  I had a colleague help me to write a script and it works when I run it on two of my datasets, but when I run it on my other datasets, I seem to be missing some values.  For example, one of my elevation datasets has 441 entries and my tidal series is 11090 entries.  When I run my script however, instead of getting something that's 441x11090, I get something that is 359X11090 and I'm not sure where the other 82 rows have disappeared to.  I've pasted in the script I'm using below.  Any suggestions on what might be causing the problem or suggestions for solutions would be greatly appreciated.  Thanks.  
>
> load Mugu_1_Elevations.txt
> load Mugu_M1_0_11012009.txt
> date=Mugu_M1_0_11012009(:,1);
> ht=Mugu_M1_0_11012009(:,7);
> elev=Mugu_1_Elevations(:,4);
> elev_Mugu=zeros(length(elev),length(date));
> for
> i=1:1:length(date)
> ind=find(elev<ht(i));
> inun_Mugu1(ind,i)=1;
> end

Why did you change the name of the output matrix from elev_Mugu to
inun_Mugu?

This line here:
> elev_Mugu=zeros(length(elev),length(date));
is very important because it sets all the data to zero, then the for
loop resets those data that satisfy your criterion to 1. By changing
the name, you have completely screwed up the routine your colleague
wrote for you. You need to either change the name back or to change
the above line to:
inun_Mugu=zeros(length(elev),length(date));

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com