LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

skipping loop iteration in for loop

how can i skip iteration in for loop of labview.?

as we simply do this in matlab like this

for i=1:32:256

0 Kudos
Message 1 of 7
(6,545 Views)

You cannot skip an iteration in LabVIEW. 

 

Depending on how you define mathematically the iterations you want to perform or skip, you can use a case structure with an empty case for the skipped values or you can do some math on the value of i to create an index "j" for your process.

 

Be aware that LV arrays and loops start with index 0 while Matlab starts at 1.

 

Lynn

0 Kudos
Message 2 of 7
(6,529 Views)
Using case structure with empty case for skipped values will be a long process as i want to skip 32 counts. I tried some math operations too but every time i increases j also increases.
Can u suggest a simpler way or any math operation to do this. And one more thing i want to do this in a nested two for loops.
0 Kudos
Message 3 of 7
(6,517 Views)

Hi nouman,

 

Can u suggest a simpler way or any math operation to do this.

I guess "1:32:256" defines a list of values like "1, 33, 65, 97, …".

To have an easier way you could use some simple math like "i*32+1" in your loop with "i" being the loop iterator!

 

Using case structure with empty case for skipped values will be a long process as i want to skip 32 counts.

Here reading the LabVIEW help for the case structure might be a great source of wisdom!

You can define ranges like "2..32", "34..64", "66..96" for just one case - as explained in the help

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 7
(6,507 Views)

Tell us more about exactly what you want to do. GerdW gave suggestions for two somewhat different interpretation of what you want.

 

You may be able to create an array of your desired "i" values using Ramp.vi. Many numeric and math functions are polymorphic, meaning that they accept array inputs and may generate array outputs. It is possible that you may not need a loop at all, depending on your algorithm.

 

Lynn

0 Kudos
Message 5 of 7
(6,499 Views)

i am doing some image processing techniques (image enhancement). I have the matlab code i am just implementing it on labview 

Here is what i have done so for on labview by using this matlab code

 

image=imread('C:\Users\Nouman Ashraf\Desktop\cameraman12.png');

I = 255-double(image);
[w,h] = size(I);
%out = I;
w1=floor(w/32)*32;
h1=floor(h/32)*32;
inner = zeros(w1,h1);
for i=1:32:w1
for j=1:32:h1
a=i+31;
b=j+31;
F=fft2( I(i:a,j:b) );
factor=abs(F).^f;
block = abs(ifft2(F.*factor));
larv=max(block(:));
if larv==0
56
larv=1;
end;
block= block./larv;
inner(i:a,j:b) = block;
end;
end;
final=inner*255;
final=histeq(uint8(final));

0 Kudos
Message 6 of 7
(6,493 Views)

Hi nouman,

 

sometimes it's better to have atleast basic understanding of the programming language you want to use…

 

- You're looking for array subsets of certain size. You're trying to create loops to iterate over your picture. Just start with creating those two for loops to index those subsets, later on you may include the FFT math too.

- Using that floor function is like translating a text word by word. Why not use a simple Quot&Rem function?

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 7
(6,484 Views)