From: Jan Simon on 12 Aug 2010 18:31 Dear Matt, > Kinda like: Why are vacuums empty? Vacuums are not empty. And for quantum-mechanical reasons the plural of "vacuum" is not well defined. Numbers are an assault on the indepency: Together with the numbers, the obligations appear. Jan
From: Rajesh on 13 Aug 2010 01:27 Thanks andy. Let me elaborate my problem. I have files named image001 to image180. I want to read them one by one in a program automatically. Only the directory will be available to me. The catch here is that the names can be in different forms like say file1 to file180 or name01 to name0180 etc. therefore i have picked up the filename of the first file and using regexp i have separated the number from the name. like in above case, say a='image' and b='001'. After this, I thought, if i get b as a number, say, c=001 i can start the loop for c=001:180, and then convert this number back to string and concat with the name part (variable a above) and read the corresponding files. but this, i guess, is not to be. any other way of doing this. Thanks.
From: Rajesh on 13 Aug 2010 02:52 I have also tried the following: lets say directory= the path of directory where the files are located. images=dir(fullfile(directory,'*.tif')); [names index]=sortrows({images.name}'); after sorting the names in the images structure i get the following sequence image1, image10, image100, image101, image102...image109, image11, image111, image112...image119, image12, image121.... etc (I have 180 images in the directory. ) If i do [names index]=sortrows({images.date}'); still doesnt give desired sequence. This time i get image1,image10,image11,image12,...image19,image2,image20,...image29,image3,image30...etc. this may be because i have copied this directory from its original location to my PC and now when i sort it using the 'date' field, it is taking the date of modification and not that of creation. thus when the date (and time) is the same it further sorts by name by default. guess i am clear now. So any other ideas here.
From: Malcolm McLean on 13 Aug 2010 02:57 "Rajesh " <rv_acharya(a)rediffmail.com> wrote in message > How can i convert the following string into the same number > > '001'(string) converted to 001 (number) > > str2num or str2double eats the leading zeros. any suggestions?? > You almost certainly want to work with the number in Matlab as a binary floating point number. It's impossible in this representation to include leading zeros. When you display it to the user, you want to represent it in Arabic denary numerals, with leading zeros. sprintf('%03d', 1); will achieve this (presuming ypu want to pad out to three decimal places);
From: Rajesh on 13 Aug 2010 08:05 > sprintf('%03d', 1); > > will achieve this (presuming ypu want to pad out to three decimal places); Thanks MM, what if i do not know how many zeros are to be padded with. i.e. I wouldnt know if its %03d beforehand. however it will be available to me as a variable. Can i use this variable in this way. e.g. sprintf('% var d',1); var can be defined just before this statement.
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: how to clear the cache (rehash clear mex ???) Next: Changing colors of stacked bar graph |