From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
03-03-2012 04:31 AM
Hi,
i want to use a MATLAB code in Labview, but without using MATLAB.
The code is the following:
Mask = ones(size(cc));
Mask(1:sze,:) = 0;
Mask(:,1:sze) = 0;
Mask(end-sze+1:end,:) = 0;
Mask(:,end-sze+1:end) = 0;
It should be a 2D array with ones and boarders with zeros. The width of the boarders are sze and the 2D array has the size of cc.
I can create an array of zeros but that's all.
Has anybody an idea how to realize it without using for-loops?
thanks....
Solved! Go to Solution.
03-03-2012 08:14 AM
If you want the elements to be different, no you have to use loops. The good news though is that if all the inputs to the loop comes from constants LV will generate the array at edit time and store the result in the VI as though it were a constant.
Mike...
03-03-2012 04:05 PM
I attach one possible solution.
You con refine it by adding:
1) Adjust the Vi such that they work as most of the array functions. This is, if you wire "rows" the column value is disabled; if you wire "cols" the row value is disabled. For simplicity I used a boolean flag.
2) Note that the array of zeros to be replaced is created with dimensions <sze x length(cc)>. Thus when replacing columns it needs to be transposed.
3) Make a input sanitation to avoid nonsquare matrices and other funny stuff.
Regards
03-03-2012 04:57 PM - edited 03-03-2012 05:33 PM
@gruenschnabel wrote:
It should be a 2D array with ones and boarders with zeros. The width of the boarders are sze and the 2D array has the size of cc.
I can create an array of zeros but that's all.
Here's what I would do:
(Attached is a LabVIEW 8.2 version of the code)
@gruenschnabel wrote:
Has anybody an idea how to realize it without using for-loops?
What's wrong with FOR loops? Why such an arbitrary restrictions?
(Unless you are on FPGA, things need to loop no matter what, even it it is hidden inside functions). 😄
03-05-2012 05:10 AM
hi,
thanks for the fast responses.i could implement the code successfully 🙂