double loops

Hi,

I am new in Matlab and I have to creat a moving window to make calculations for my research. I did it with the help of double loop which looks like this:

for c=417:500
for j=1:c

    matrix(:,:,j,c)=y(:,j)*y(:,j)'-S(:,:,c)
 end
end
where "y" is 21 by 500 matrix of data, S is 21 by 21 by 500 matrix of data

The problem is that as "c" starts from 417, MATLAB first calculate 417 matrixes of "0" (number of "j") for 1:417 times (number of "c"). Only after that it starts to calculate the data that I need (for "c" equal from 417 to 500). Calculation of these first matrixes of "0" take long time, so does anybody know how to create a code which will start directly from 417 so I can speed up a process? 

Many thanks an advance,

Katerina  
0
10/16/2009 11:34:04 PM
comp.soft-sys.matlab 206968 articles. 0 followers. lunamoonmoon (258) is leader. Post Follow

1 Replies
91 Views

Similar Articles

[PageSpeed] 35
On Oct 16, 7:34=A0pm, "Ekaterina Ipatova" <eipat...@list.ru> wrote:
> Hi,
>
> I am new in Matlab and I have to creat a moving window to make calculatio=
ns for my research. I did it with the help of double loop which looks like =
this:
>
> for c=3D417:500
> for j=3D1:c
>
> =A0 =A0 matrix(:,:,j,c)=3Dy(:,j)*y(:,j)'-S(:,:,c)
> =A0end
> end
> where "y" is 21 by 500 matrix of data, S is 21 by 21 by 500 matrix of dat=
a
>
> The problem is that as "c" starts from 417, MATLAB first calculate 417 ma=
trixes of "0" (number of "j") for 1:417 times (number of "c"). Only after t=
hat it starts to calculate the data that I need (for "c" equal from 417 to =
500). Calculation of these first matrixes of "0" take long time, so does an=
ybody know how to create a code which will start directly from 417 so I can=
 speed up a process?
>
> Many thanks an advance,
>
> Katerina =A0

-------------------------------------------------------------------------
Katerina  :
I can't really tell what you're doing.  You have 2D and 3D matrices
and then end up with a 4D matrix.  Too complicated for me to figure
out.  I'm not that good at visualizing hyper-dimensional image space.
I don't know what that 4 dimensional array means.  Can you explain
what you want to do in words?  Do you want to do something like a
convolution or a sliding window type of filter?  As a wild guess,
maybe you can check out these functions:
bsxfun(), convn(), imfilter()
-ImageAnalyst
0
imageanalyst (7623)
10/17/2009 12:38:52 AM
Reply:
Similar Artilces:

how to load a text file using a loop
hello, i have several(nearly 150)text files each having a column vector. i want to load these files to an m-file. how to do it using a loop and load command or in any other way. i tried using num2str, but i had problems later on, bcos i have to copy this data into a 3d matrix. pls help, thanx in advance sravanthi some steps use dir to get in an array the filenames of your files x =zeros(matrix of appropriate size) for i = 1 to nfilenames x(i,:) = load(filename{i},'-ascii') end; sravanthibaltam@yahoo.com (sravanthi) wrote in message news:<r5huwfnxp2o8@legacy>... > hello...

MAC sends double attachments
Hi! I have a strange problem... When MAC clients send an e-mail with certain types of attachments, they arrive twice(the right file and a smaller one that is not openable). Better, if i send DOC, PLN, BMP files it happens. If i send DWG, XLS, PDF files all works correctly, only the right file is sent. Any ideas ? ? ? Thank you in advance!!! Mark ...

drawn lines are doubled
I'm working on a ortho mode application on Ubuntu linux with a nvidia card. Horizontal and diagonal lines have started being drawn as closely spaced double lines. But not always, now and then I get single lines like they should be. I'm thinking that it might have something to do with vertical retrace timing of my hardware, but am not sure. Does anyone have an idea? thanks, Bob On Jul 6, 12:28=A0pm, bob <bobs...@xyzzy.com> wrote: > I'm working on a ortho mode application on Ubuntu linux with a nvidia > card. Horizontal and diagonal lines have started being drawn ...

++ / -- operators with floats and doubles
Yesterday I found in a piece of code a float being incremented with ++. For some reason (wrong, I guess...) I thought that only integer types could be incremented that way, and I had never seen floats or doubles incremented that way before. Just to be sure I did a toy program and compiled with gcc -ansi -pedantic -Wall and it worked without any error or warning, showing the correct result. Is it correct to increment floats or doubles with ++ and --? Is it defined or am I getting into the realm of undefined behaviour? If it's correct, can you think of a place where it could be useful? Many ...

double 0.00274 == double 0.000274 ??
Hi all, in my program, i set up two double numbers, say double a = 0.00274; double b = 0.000274; Those a and b are used paramters and so they are not supposed to change while program runs. In parameter section of my output, however, those two values come out same. a = 0.00274 b = 0.00274 I don't understand what's going on here. Does anyone have any ideas? Thank you. Jong-Hoon Jonie wrote: > I don't understand what's going on here. Does anyone have any ideas? There is a bug in your code. The code you didn't show. You could e.g. use a debugger to trace where ...

Matrix reduction without loops?
I have a large binary matrix (A) and use a column of identifiers (H) throughout the program. At some point I need to use the binary values in A for only the row values in H. To do this I want to create an A_TEMP matrix which would be only the rows corresponding to values in H but I am not sure how to do this without using a growing matrix in a loop. I think there is an easy way to do this but it isn't coming to me. Below is an example of what I am trying to do: A = [1 0 1 1 0 0 0 1 0 0 1 0 1 0 1 1 1 0 0 0 1 1 0 0 1 1 0 1 1 1 1 1 0 0 0] H = [1 2 3 4 5]' Then Later on H has been ...

Vectors\Loops Continued
**First Run********************** data list list (",")/ var1 to var10 (10f1.0). begin data 1,1,1,,,,,2,2,2 1,1,,,2,2,,,,, 1,,,,,,,,2,2 end data. vector A=var1 to var10. loop #C=1 to 10. if(A(#C)>=1 and missing(A(#C+1)))PositionBeforeMissing=#C. break. end loop. exe. **Second Run************************* data list list (",")/ var1 to var10 (10f1.0). begin data 1,1,1,,,,,2,2,2 1,1,,,2,2,,,,, 1,,,,,,,,2,2 end data. vector A=var1 to var10. loop #C=1 to 10. if(A(#C)>=1 and missing(A(#C+1)))PositionBeforeMissing=#C. end loop if (missing(A(#C)))....

Avoid double for loop
Any ideas how I reduce this double for loop? T = 40; price = rand(T,1); strike = rand(T,1); %%I know i can generate both of them simultaneously but this is just a snippet to give you an idea of what I want to do... for i=1:T for j=1:T-1 intrinsic(i,j) = price(j+1)-price(i); end end In article <fnsqle$s8j$1@fred.mathworks.com>, Anish Goorah <anish.goorah@gmail.com> wrote: >Any ideas how I reduce this double for loop? >T = 40; >price = rand(T,1); >strike = rand(T,1); %%I know i can generate both of them >simultaneously but this is just a snippet t...

Materials doubling as *materials*
Sometimes materials double up in material list and the copies show up as *material*. This is not a big deal, but it's boring to delete each of them again and again.. -Andrei ...

Problem with double for loop... help!
Hi, &nbsp; I am very stuck, with this problem, i suppose is stupid problem, but i cant see it.. &nbsp; I attached the vi. My problem is when I use the double for loop to looking for the values of source array between 2 elements from another array, when the vi 'search 1d array', when the values is out of range, put 0 on the rest of array elements, and i would like remove all the 0, i want the double for loop, show only the index from the values between these elements. I know each time the for loop search the range, and when it doesn't find any value put 0, but i dont know d...

if then test in loops...
Hi, I use this kind of test in loops: ismin = i1 - nsx if (ismin < 1) then ismin = 1 end if ismax = i1 + nsx if (ismax > nx) then ismax = nx end if How can I compute it efficiently, knowing that these tests are in ijk loops ? TIA. Cheers, PS: I use ifort 9.1 on x86_64/i686 debian arch. -- http://scipy.org/FredericPetit "fred" <fredantispam@free.fr> wrote in message news:87wsuj91rp.fsf@free.fr... > > Hi, > > I use this kind of test in loops: > > ismin = i1 - nsx > if (ismin < 1) then ...

how to bracket path/filename in double quotes
The following script, from the May issue of Linux Journal, uses 'icat' to restore files, including their full path. But it fails on paths that contain spaces, such as "Program Files", and I'm not handy enough with scripting to figure out how to bracket the entire path/filename in double quotes. #!/bin/bash DISK=/dev/sdb1 # disk to scan RESTOREDIR=/home/kyle/recovery # directory to restore to mkdir -p "$RESTOREDIR" cat $1 | while read line; do filetype=`echo "$line" | awk {'print $1'}` filenode=`echo "$line" | a...

Why does one while loop stop after 3-4 weeks?
I have a fairly large vi that has about 16 parallel while loops. These read from serial instruments every 5-20 seconds, write data to log files every few minutes, look for button presses, communicate with a FieldPoint unit, etc. I am using LabVIEW 7 running under Windows XP Professional. One particular while loop, which communicates with a serial instrument, has stopped twice after the vi has been running for 3-4 weeks. All the other while loops continue to execute. The loop that stops has a Boolean constant wired to its loop condition so it should not stop until a different loop halts the vi ...

double usingle multiply with double returned
Hello, Let me first state that I am new to Forth. I am trying to write a program for a circa 1985 device with its embedded Forth. The Forth is a subset of Forth-83 and is missing a few words, e.g. M*/. I've search for a definition of M*/ using other Forth words without any luck. What I need is a multiply (d u -- d). I have already created my own multiply but I suspect that it is not very efficient and thought I'd reach out here. My implementation (grade school multiply): DUP ROT ROT UM* SWAP 2SWAP UM* D+ Thanks. Op Sat, 28 Feb 2009 10:38:51 -0800 (PST) schreef datajerk: >...

double loop
Dear All, I cleared up the notebook but when I plot the picture I don't recover the contour plot desidered.  The colours should be the different correlation coefficient and it is not the case. I will be grateful if you could help Maria   h=0.71 ckms=299792.5 HubE[z_,Om_,Ol_]:=SQRT(Om*(1+z)^3+Ol)dL[z_,Om_,Ol_,h_]:=3.0856*1018*106*ckms/(100*h)*(1+z)*NIntegrate[1/HubE[z,Om,Ol],{z,0,z},MaxRecursion ->100] TabOmegalambda=Table[i,{i,0.1,1.1,0.05}] TabOmegaM=Table[i,{i,0.0,1.0,0.05}] LxOmegalambda={}; Do[ Ol=TabOmegalambda[[k]]; LxOmegaM={}; Do[ Om=TabOmegaM[[...

double linked list #2
I have a simple implementation of double linked list this code is crashing if i enter values not present in the linked list(during insertion) or if i try to delete values not present in the list can u suggest how can i avoid it? #include<stdio.h> #include<stdlib.h> #include<ctype.h> void main() { int i,n,c,x,m,flag=0; struct node{ struct node* next; int data; struct node* prev; }*h,*t,*start,*last,*z,*p,*q; printf("enter the number of nodes"); scanf_s("%d",&n); if(n<=0) { printf("no of nodes cannot be %d\n",n); exit(0)...

Inspector goes into infinite loop
I have meet this bug when I demonstrated Smalltalk agile magic to my numb C++ programmer friends ;-) So, in the fresh Comminity Edition image try to Ctrl-D this in Workspace: Object allInstances. You'll see something like this: #(an Object an Object an Object an Object an Object an Object). If you try to inspect this array you will inspect an infinite loop of the Inspector :) Second object of this array causes this behavior. I.e. Object allInstances second <Ctrl-I> will crash Inspector too. This object used in RetryCookie class variable in the ExceptionHandlerAbstract...

Printing double-type Simplified Chinese characters
We would like to directly print double-type Simplified Chinese characters (based on Reflection=92s GB Chinese coding) from a HP3000 to standard LaserJet printers. Answers to any of these questions would help. 1. HP made a DIMM for Simplified Chinese (C4293A). Does anyone know of a USA supplier that still has any of the DIMMs? 2. Does anyone know there I can get a downloadable soft font (.SPF file) for a Simplified Chinese font? 3. Does anyone know of a product that will convert a double-byte true type (TTF) to downloadable soft fonts (.SPF files)? 4. It looks like a true type ...

Sorting double precision values
Can someone point me to a C algorithm for sorting double precision values that is stable with duplicates? Thanks, Graham GrahamWilsonCA@yahoo.ca (Graham) writes: > Can someone point me to a C algorithm for sorting double precision > values that is stable with duplicates? If you're not too concerned about performance, I suggest insertion sort http://www.nist.gov/dads/HTML/insertionSort.html It is easy to make it stable. If performance is a concern, enhancing the data structure and comparison to include the original position is the easiest. Merge sort is also easy to make sta...

Double Quotes in XML
I'm trying to do something similar to the following: <?xml version="1.0" encoding="utf-8"?> <Rules id="ruleset1"> <Rule num="1"> <Description>Foo must equal "bar".</Description> <Code>Foo = "bar"</Code> </Rule> </Rules> I'm reading the actual rules and descriptions in from a giant file and when i spit it back out into an xml file i get errors involving the quotes around bar. Looking at examples that should be working i notice there's a difference between ...

double to currency and currency to double
hello, I have an app that pops up a custom dialog box and one of the fields for user input is an account balance field. The data gets put into an Object and eventually into an instance of DefaultListModel. When I use getText() on the field I pass it to Double.parseDouble to convert it so I can store it as a number and not a string. When I display it (either in the list or in the dialog box) I want it to be displayed using currency format and I display it in my list using toString() along with other fields. I just concatenate all of them together and return them in the toString()...

How to input datas apply loop statement?
The time ranges from 0 to 10,so there are 11 datas for Yvv and Yuu Yvv t 0 1 2 3 4 5 6 7 8 9 10 Yvv 7 4 9 2 7 8 7 2 6 5 2 Yuu t 0 1.5 2.6 3.5 4.5 5.5 6.5 7.5 8.5 9.8 10 Yvv 7 4 9 2 7 8 7 2 6 5 2 ...

onversion to double from sym is not possible!!
Hello.. The program is and the error as below. I would be thankful if you could please help me with that. Thanks, Sincerely yours Harsh Agarwal Undergraduate Student Virginia Commonwealth University Richmond, VA clear all clc syms t J=1; Z=0; c=3; hA=c*J; hB=c*J; A=[2*J-hA-hB-3*Z 0 0 0 0 0 0 0 0 -hA+hB-Z 2*J 0 0 0 0 0 0 2*J -2*J-hA-hB-Z 0 2*J 0 0 0 0 0 0 -hA+hB+Z 0 2*J 0 0 0 0 2*J 0 hA-hB-Z 0 0 0 0 0 0 2*J 0 -2*J+hA+hB+Z 2*J 0 0 0 0 0 0 2*J hA-hB+Z 0 0 0 0 0 0 0 0 2*J+hA+hB+3*Z]; [V,D]= eig(A); expD=[exp(D(1,1)) 0 0 0 0 0 0 0 0 exp(D(2,2)) 0 0 0 0 0 0 0 0 exp(D(3,3)) ...

Re: append variables to macro variable with loop #3 1551405
Hi Dirk, Looping to add in the pieces in the expression part of the assignment is perfect if the %do was in a datastep assignment, then the macro multiple pieces would be in the datastep assignment statement because the macro processing is completed before the datastep is submitted and the replacement text would already be completed and the datastep statement would be as expected. However, since we are doing this all in the macro goodies it will not work having a %DO statement inside a %LET statement. Embedding one macro statement inside another does not work. Basically the same similar rules...

converting single values into double
hi all how can one convert single values into double values thanks to all aa schrieb: > hi all > > how can one convert single values into double values > > thanks to all >> a=single(3.3) a = 3.3000e+000 >> b=double(a) b = 3.3000e+000 ...