**while loop in a while loop**Hi all,
I am trying to write a program with a while loop within another while loop. When I run the vi both while loops run but then only the inner while loop seems to update, I adjust controls and they have no effect on the indicators.
Thanks..
You need to familiarize with the concept of dataflow programming. Run your VI in "execution highligthing" mode while watching the diagram and you'll get a better feeling on how things work. :)
If both loops need to run in para...

**LOOP and +LOOP**With LOOP, since the index (I) increases by 1 with each loop
iteration, we can test for equality as a means to determine if it's
time to exit the loop or not:
: TEST 10 0 DO I . LOOP ;
TEST
0 1 2 3 4 5 6 7 8 9
Here, when I gets to 10, the loop exits.
It's not so easy with +LOOP, since the index can be changed by any
arbitrary value on each iteration:
: TEST 100 0 DO I . RANDOM +LOOP ;
Here, we cannot test for equality. We have to test for crossing a
boundary instead, at least as far as I can see.
With that in mind, are these following results correct:
: TEST 10 0 DO I . 1 +LOOP ...

**double for loop**Hi,
I am trying to modify the content of a 2D for loop using a double for loop. But the result I am getting is always 0 in the loop i am getting... I am not really too sure of the problem. Can anyone help?
Thanks
example2.vi:
http://forums.ni.com/attachments/ni/170/215997/1/example2.vi
...

**while loop in a while loop**Hi All,
I have the following situation:
while(rs.next()) { //loop1
while(rs2.next()) {
//loop 2
}
}
It seems like loop 2 is only beeing used once. Should I after loop2 put the
cursor back to the beginning? if so, how do I do that?
Thanks!
--
Posted by news://news.nb.nu
Steven wrote:
> Hi All,
>
> I have the following situation:
>
>
> while(rs.next()) { //loop1
>
> while(rs2.next()) {
> //loop 2
> }
>
> }
>
The architypal loop (for a List eg ArrayList of Blah objects) is:
for(It...

**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[[...

**For loop over a while loop**Hi,
I am computing a quantity that depends on two variables. The computation itself is iterative (i'm using 3 while loops to compute it). Now i want to do a sensitivity analysis of the input variables and do a 3D plot where I can start making sense out of my results, however not sure how to write a for loop over these while loops to compute different combinations of what I define as my parametric space for my two input variables.
Thanks in advance,
Vash
Please add a code example and/or more specific question....
...

**double loop do**Dear Mathgroup,
I have a problem with a double loop. Formally it doesn't give any error message but it doesn't let Om variate in the loop, it takes only the first value 0.1.
This is the code
ckms=299792.5HubE[z_,Om_]=(Om*(1+z)^3+(1-Om))^1/2dL[z_,Om_,h_]:=3.0856*1018*106*ckms/(100*h)*(1+z)*NIntegrate[1/HubE[xh=0.71TabOmegaM=Table[j,{j,0.0,1.0,0.01}]
LxOmegaM={};
Do[
Om=TabOmegaM[[j]];
DataGood={};
Do[
logTarest=DataGRB[[i,7]];
logTaErrrest=DataGRB[[i,8]];
Fx=DataGRB[[i,3]];
FxErr=DataGRB[[i,4]];
idGRB=DataGRB[[i,1]];
DataGRB[[i,2]];
class=DataGRB[[i,12]];
beta=Dat...

**For loop while loop**I need to evaluate a function from 0:200 then create an
array of every 5th value in the 0:200 array using a for
loop then using a while loop.
I can't get the for loop to work at all because I cannot
use >,< controllers, only an =.
So I focused on the While loop:
n=0:200;%creates 201 cell array from 0-200
x=n.^2+.25;%calculates x
plotcol=(length(n)-1)/5;%=(201-1)/5=40
y=zeros(1,plotcol);%creates 1X40 vector
col=1;%used for incrementing in while loop
while col<=plotcol;
y(1,col)=x(1,5*col);
col=col+1;
end
Unfortunately the output starts at 16 when it should start ...

**Loop in a loop?**Hi,
I'm new to Python and have come across a problem I don't know how to
solve, enter com.lang.python :)
I'm writing some small apps to learn the language, and I like it a lot
so far.
My problem I've stumbled upon is that I don't know how to do what I
want. I want to do a loop in a loop. I think.
I've got two arrays with some random stuff in, like this.
array1 = ['one','two','three','four']
array2 = ['a','b','c','d']
I want to loop through array1 and add elements from array2 at the end,
so it looks lik...

**loop not looping**This should be relatively easy for someone more experienced to pick out what I'm doing wrong here...All I want is my loop to run as many times as there are .dat files in the specified directory. I've hacked up my code a bit just so i can get it to work and realize it's not as simple or efficient as it could be. My script only runs through the loop once and I can't figure out why it never loads 'binary_002.dat' and so on.
thanks for your help
counter_value = 1; %counter value set back to 0 when while loop = false
slice_thicknessMM = 1.5;
tf = isdir('C:\Documen...

**loops in loops**In the attached vi, the one second loop runs at one second and can't be touched. In the ten second loop, the ten second clock is a stand in for a process that generates a finished signal. The problem is once the process is complete, to start it again, leave the one second loop running, and start an additional process that will take less time than 10 seconds. thanks
internal loops.vi:
http://forums.ni.com/attachments/ni/170/319512/1/internal loops.vi
Hi exo,
what do you try there? If you start your vi, the value from your stop button will be read and after that, both loops &quo...

**for loop into for loop.**Hello this is my first time that i am writing here..
I need your help to improve my code. This is my code
for a=1:numberOfShortestPaths
for b=a+1:a+numberOfShortestPaths
for c=b+1:b+numberOfShortestPaths
for d=c+1:c+numberOfShortestPaths
for e=d+1:d+numberOfShortestPaths
total_weight=weight(:,:,a)+weight(:,:,b)+weight(:,:,c)+weight(:,:,d)+weight(:,:,e);
maximum=max(total_weight);
end
end
end
end
end
i want to do this function "automatically" because the letters ...

**double for loop**Hi,
I have three large matrices, one for the x position, one for the y position and one for the z value.
Ideally, I need to extract each value, i.e. x=X(1,1) y=Y(1,1) and z=Z(1,1) and to 3D plot all of the values extracted.
I think a double for loop would be good,
for f = 1:480 & d = 1:752
etc. but this doesn't work.
Thanks.
"tommy Owen" <jesse9021074@hotmail.co.uk> writes:
>I think a double for loop would be good,
Start matlab and type
help for
at the prompt. You'll see an example of the kind of thing
you're trying to do.
...

**30% faster for-loop when changing loop variable from default(double) to int**When testing a very simple program and trying to change the for-loop variable from double to int (Why did I do that?), I found the program becomes faster, about 30%.
The program is as following:
function k=pbug_d(N)
p=0.3;
for i=1:N
p=3.4*(p*(1-p));
end
k=p;
end
On my PC (Pentium 6700, Win7, MatlabR2010b), the command
tic, pbug_d(1e9),toc
took 9.3s.
When I changed the for-loop variable to int type:
function k=pbug_i(N)
p=0.3;
i=int32(1);
for i=1:N
p=3.4*(p*(1-p));
end
k=p;
end
the c...

**Having trouble stopping a loop (or loop de loop de loop)**Hi again everyone,
Here is my rather clunky code (and I know it is rather inefficient):
------------------------------------------------------------------------------------------------------------------------------
while e_t lt 2 do begin
for x=4e003, 20e003, 4e003 do begin
for c=0.006, 0.01, 0.004 do begin
for o=(50*!pi/180), (70*!pi/180), (10*!pi/180) do begin
v= (a*x)
ind_small = where(file[1,*] lt 2*x,count)
if count eq 0 then te_small=0
if count gt 0 then begin
ext_small = file[*,ind_small]
le_small= ext_small[1,*]
te_small = total(le_small^3)
endif
ind_large = where(file[1,*] ge...

**Nested FOR loops. (a loop within a loop)**I can't get my head around them.
I have two MySQL tables, one contains the categories, the other contains
the posts. Each post is linked to a category.
Now I'm trying to display each post with a drop down menu that has the
categories in it and have the category that the post is in selected.
Here's my code for the drop down menu where my woes lie.
for ($i=0; $i<count($posts); $i++) {
for ($j=1; $j<=count($categories); $j++) {
if ($j == $post[$i]['id']) {
selected = ' selected="selected"';
} else {
sele...

**what diference between timed loop and while loop and for loop**If I want to count 2 second working in the loop and next then going out of the loop
I don't know which the loop I can use Message Edited by Jairak on 07-26-2008 03:14 PM
Why do you need a loop to count for 2 seconds? To learn more about LabVIEW it is recommended that you go through the tutorial(s) and look over the material in the NI Developer Zone's <a href="http://zone.ni.com/devzone/cda/tut/p/id/5054" target="_blank">Learning Center</a> which provides links to other materials and other tutorials. You can also take the <a href=...

**When is double not double? (converting from string to double)**I've remember reading about something like this somewhere before but could someone please explain this to me?
IDL> x = '133.359996'
IDL> print, double(x)
133.36000
On 18.05.2014 07:33, Tim B wrote:
> I've remember reading about something like this somewhere before but could someone please explain this to me?
>
> IDL> x = '133.359996'
> IDL> print, double(x)
> 133.36000
>
https://www.idlcoyote.com/math_tips/sky_is_falling.html
The number x is just fine, the way you print it is not:
IDL> x = '133...

**Triple nested loop python (While loop insde of for loop inside of while loop)**try to make my triple nested loop working. My code would be:
c = 4
y1 = []
m1 = []
std1 = []
while c <24:
c = c + 1
a = []
f.seek(0,0)
for columns in ( raw.strip().split() for raw in f ):
a.append(columns[c])
x = np.array(a, float)
not_nan = np.logical_not(np.isnan(x))
indices = np.arange(len(x))
interp = interp1d(indices[not_nan], x[not_nan], kind = 'nearest')
p = interp(indices)
N = len(p)
dt ...

**double for loop #2**Can someone explain to me the mechanics for a double for loop?
[x,y] = size(z)
for ii = 1:x;
for jj = 1:y;
newz = z(ii,jj)
end
what is the sequence being played out? A geometric interpretation would be good.
"cwc" wrote in message <l0k71e$5g7$1@newscl01ah.mathworks.com>...
> Can someone explain to me the mechanics for a double for loop?
>
> [x,y] = size(z)
>
> for ii = 1:x;
> for jj = 1:y;
>
> newz = z(ii,jj)
>
> end
>
> what is the sequence being played out? A geometric interpretation would be good.
The ...

**How to speed this double for loop up?**Hi, i have one newbie question
If i have a matrix xdim*ydim*3, and i want to make a vector (xdim*ydim)*5,
how can i write it more compact ad spped it up?
Tnx
k=1;
for i=1:xdim
for j=1:ydim
vector(k,:)=[i j mat(i,j,1) mat(i,j,2) mat(i,j,3)];
k=k+1;
end
end
So how to write this in a mor simple way?
% Sample data
x = 2; y = 4; z = 3;
mat = reshape(1:x*y*z,x,y,z);
% Algorithm
[X,Y] = ind2sub([x,y],1:x*y);
matP = permute(mat,[3 1 2]);
vector = [X' Y' reshape(matP(:),3,[])'];
tnx mate :-)
"Trevor" <trevbassNOSPAM@hotmail.com> wrote in message
news:ef5d2...

**double loop optim**hi,
-----------
#include <iostream>
#include <omp.h>
int main()
{
const double p0 = 0.51;
const double p1 = 0.49;
const int N = 100000;
double opt[N];
for (int i=0; i<N; i++)
opt[i] = i;
const double t0 = omp_get_wtime();
for (int ts=N-1; ts>0; ts--)
for (int i=0; i<ts; i++)
opt[i] = p0*opt[i] + p1*opt[i+1];
const double t1 = omp_get_wtime();
std::cout<< t1-t0 <<std::endl;
}
-----------
I use the intelc++ compiler and build it with
icpc -xT -O3 -openmp -o 2 2.cpp
I have a xeon core2duo (SSSE3) L2 2M cache
Is there a particular SSE? instruction...

**speed up double for loop**Hi there,
I am a newbie for matlab and I wish that I can get some
help on this question...
for c=1:n
for d=c+1:n
if Dist(c,d)<= max_dist
edge_matrix(c,d)=1;
edge_matrix(d,c)=1;
end
end
end
where max_dist= predefined constant
Dist = previous matrix that has been calculated
edge_matrix= matrix with 1's and 0's
Is there anyway I can speed up this without the double for
loop? Thank you in advance...
"Wen Pinn Yee" <wpyee11@mathworks.com> wrote in message
&l...

**double for loop #3**Can someone explain to me the mechanics for a double for loop?
[x,y] = size(z)
for ii = 1:x;
for jj = 1:y;
newz = z(ii,jj)
end
what is the sequence being played out? A geometric interpretation would be good.
On 9/9/2013 5:20 AM, cwc wrote:
> Can someone explain to me the mechanics for a double for loop?
>
> [x,y] = size(z)
>
> for ii = 1:x;
> for jj = 1:y;
>
> newz = z(ii,jj)
>
> end
>
> what is the sequence being played out? A geometric interpretation would be good.
>
There is matrix z with x rows and y columns.
The l...