From: Justme on 28 Jun 2010 13:17 So, upon further searching, I will have to do a bit more than I thought..originally I had this script so that as a user, you could call times manually one by one. With this automated script, looks like i'm going to have to try to make a loop of some sorts because it is reading in multiple times as opposed to just one set of times. This may be a bit more sticky...any input is appreciated. "Justme " <sadsd(a)aol.com> wrote in message <i0ainc$j3h$1(a)fred.mathworks.com>... > To give an update this is what i've modified so far.... > > Dummytext_filename = 'C:\Documents and Settings\Moi\Desktop\InterpTestRead.txt'; > FLT_filename = 'Textread1'; > SIM_filename = 'Textread2'; > > [startflt stopflt startsim stopsim] = textread(Dummytext_filename,'%*s%*s%*s%f%f%f%f','delimiter','.'); > [time1 data1] = textread(FLT_filename,'%f%f'); > [time2 data2] = textread(SIM_filename,'%*s%f%*s%*s%f%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s'); > > ind = find(time1 >= startflt & time1 <= stopflt); > > ind2 = find(time2 >= startsim & time2 <= stopsim); > > But I get an error saying: > > Error using ==>le > Matrix dimensions must agree > > Error in ==> TestAir at 18 > ind = find(time1 >= startflt & time1 <= stopflt); > > Again, I just made these adjustments and keep tinkering along the way.
From: dpb on 28 Jun 2010 14:10 Justme wrote: > To give an update this is what i've modified so far.... > > Dummytext_filename = 'C:\Documents and > Settings\Moi\Desktop\InterpTestRead.txt'; > FLT_filename = 'Textread1'; > SIM_filename = 'Textread2'; > > [startflt stopflt startsim stopsim] = > textread(Dummytext_filename,'%*s%*s%*s%f%f%f%f','delimiter','.'); .... > ind = find(time1 >= startflt & time1 <= stopflt); > > ind2 = find(time2 >= startsim & time2 <= stopsim); > > But I get an error saying: > > Error using ==>le > Matrix dimensions must agree > > Error in ==> TestAir at 18 > ind = find(time1 >= startflt & time1 <= stopflt); From that I presume the file contains more than one input line so that length(startflt) > 1. Logical operations in Matlab are either a comparison of a scaler to an array or vector that returns the locations that satisfy that condition as a logical or if both arguments are nonscalars, an element by element comparison returning a result of the same size. It would, as noted earlier, be helpful if you gave more detail as to the data format although from the above I guess one can infer the time is simply a numeric number of seconds from some arbitrary point? --
From: Justme on 28 Jun 2010 16:00 dpb <none(a)non.net> wrote in message <i0aon7$tb8$1(a)news.eternal-september.org>... > Justme wrote: > > To give an update this is what i've modified so far.... > > > > Dummytext_filename = 'C:\Documents and > > Settings\Moi\Desktop\InterpTestRead.txt'; > > FLT_filename = 'Textread1'; > > SIM_filename = 'Textread2'; > > > > [startflt stopflt startsim stopsim] = > > textread(Dummytext_filename,'%*s%*s%*s%f%f%f%f','delimiter','.'); > ... > > ind = find(time1 >= startflt & time1 <= stopflt); > > > > ind2 = find(time2 >= startsim & time2 <= stopsim); > > > > But I get an error saying: > > > > Error using ==>le > > Matrix dimensions must agree > > > > Error in ==> TestAir at 18 > > ind = find(time1 >= startflt & time1 <= stopflt); > > From that I presume the file contains more than one input line so that > length(startflt) > 1. > > Logical operations in Matlab are either a comparison of a scaler to an > array or vector that returns the locations that satisfy that condition > as a logical or if both arguments are nonscalars, an element by element > comparison returning a result of the same size. > > It would, as noted earlier, be helpful if you gave more detail as to the > data format although from the above I guess one can infer the time is > simply a numeric number of seconds from some arbitrary point? > I apologize. You are right though. Time is just a numeric number of seconds from an arbitrary point. Allow me to see if I can shed some light. So there are multiple files being read from this script. The first, dummytext (which I am trying to work on), is simply the start/stop times of both two different types of data, lets say it's truth data and experimental data, so that I have start stop times of both truth and experimental, which I am trying to interpolate. That actually is the chunk of my script, which is the actual process of aligning times to ensure proper interpolation, which I had not put down because I did not think that was needed for this matter. The two other input files that I am reading from are both the actual data of the truth and experimental files, textread1 and textread2. So I have the times that normally the user could input (dummytext) that now I am trying to just be read in, compare it to the truth and experimental data (textread1 and textread2) and output multiple plots based on that. Does that make a bit more sense?
From: dpb on 28 Jun 2010 16:19 Justme wrote: > dpb <none(a)non.net> wrote in message > <i0aon7$tb8$1(a)news.eternal-september.org>... >> Justme wrote: >> > To give an update this is what i've modified so far.... >> > > Dummytext_filename = 'C:\Documents and > >> Settings\Moi\Desktop\InterpTestRead.txt'; >> > FLT_filename = 'Textread1'; >> > SIM_filename = 'Textread2'; >> > > [startflt stopflt startsim stopsim] = > >> textread(Dummytext_filename,'%*s%*s%*s%f%f%f%f','delimiter','.'); >> ... >> > ind = find(time1 >= startflt & time1 <= stopflt); >> > > ind2 = find(time2 >= startsim & time2 <= stopsim); >> > > But I get an error saying: >> > > Error using ==>le >> > Matrix dimensions must agree >> > > Error in ==> TestAir at 18 >> > ind = find(time1 >= startflt & time1 <= stopflt); >> >> From that I presume the file contains more than one input line so >> that length(startflt) > 1. >> >> Logical operations in Matlab are either a comparison of a scaler to an >> array or vector that returns the locations that satisfy that condition >> as a logical or if both arguments are nonscalars, an element by >> element comparison returning a result of the same size. >> >> It would, as noted earlier, be helpful if you gave more detail as to >> the data format although from the above I guess one can infer the time >> is simply a numeric number of seconds from some arbitrary point? >> > > > I apologize. You are right though. Time is just a numeric number of > seconds from an arbitrary point. Allow me to see if I can shed some > light. So there are multiple files being read from this script. The > first, dummytext (which I am trying to work on), is simply the > start/stop times of both two different types of data, lets say it's > truth data and experimental data, so that I have start stop times of > both truth and experimental, which I am trying to interpolate. That > actually is the chunk of my script, which is the actual process of > aligning times to ensure proper interpolation, which I had not put down > because I did not think that was needed for this matter. The two other > input files that I am reading from are both the actual data of the truth > and experimental files, textread1 and textread2. So I have the times > that normally the user could input (dummytext) that now I am trying to > just be read in, compare it to the truth and experimental data > (textread1 and textread2) and output multiple plots based on that. > Does that make a bit more sense? OK, I'd do something like 1) read the file containing the start/stop times. That'll give you an array of size ntimes by 2. That is assuming there are multiple times for each set of data, not just one set for all. 2) get the data file names from somewhere--I would suggest the dir() function is ideal for this rather than trying to build names dynamically. See FAQ 4.12 or the doc for examples. 3) You can either loop over the number of lines in the start/stop array and use the tstart(idx) and tend(idx) as the values or over the number of files and then the times depending on which is the overall driver in the analysis; I can't tell from the description whether it's multiple time steps for a given set of data or one for each or what but you can arrange it however suits the intent/need. 4) once you have a set of data and a single tstart/tend, then to analyze you can use logical addressing to do something like d1 = data(t>=tstart(idx) && t<=tend(idx)); where it's assume a dataset is in the array data and has the same length (rows) as the time vector, t. Of course, it's quite possible t is simply a column in data in which there's no reason it even has to be turned into another variable it could be d1 = data(data(:,1)>=tstart(idx) && data(:,1)<=tend(idx)); assuming it is the first column. Again, not exact as you've still not described the situation precisely enough to do that but a general idea... --
From: dpb on 28 Jun 2010 16:31 Justme wrote: .... > [time2 data2] = textread(SIM_filename, ... >'*s%f%*s%*s%f%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s'); .... BTW, a syntax idiom you might find useful... fmt = ['*s%f%*s%*s%f repmat('%*s',1,18)]; [time2 data2] = textread(SIM_filename, fmt); --
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: Axis and Textread Question Next: Covariance Matrix with NaNs |