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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Matlab script I need to input into labview?

Hi there,

 

I have the following matlab script, whereby I am trying to input it into labview without using the MathScript or Matlab Script nodes. Do you have any idea how??

 

----- I understand that below 3D matrices don't exist in LabView so I attempted to use a index array and initialize array functions.


% Build empty u, v, b matrices
u=zeros(length(x), length(y), length(t));
v=zeros(length(x), length(y), length(t));
b=zeros(length(x), length(y));
h=zeros(length(x), length(y), length(t));

% Define initial condition
h(:,:,1)=ones(length(x),length(y),1)*4000;
      for j=1:length(y)
 for I=1:length(x)
if x(I)<600000&x(I)>500000
            h(I,:,1)=4000-3*sqrt(3)/2*H*sech(k*(x-500000)).^2.*tanh(k*(x-500000));   
end          
    end
 end

 

Many Thanks

0 Kudos
Message 1 of 6
(2,900 Views)

Initialize array (resized for three indices, except for "b", which is 2D) is the correct tool to create the 3D arrays. To fill them with data, use "replace array subset". Possibly in a loop if needed.

 

See how far you get.

0 Kudos
Message 2 of 6
(2,897 Views)

Hi, I attempted it as you said, however I am a little unsure as how to wire the values of the 'replace array subset' with the 'Initialize array'. 

 

I'm sorry my attempt is a little pathetic but I have no knowledge of labVIEW what's so ever. please find it attached.

 

Thank you very much

salma

0 Kudos
Message 3 of 6
(2,866 Views)

I am curious what possesed you to make all three dimensions "infinite". You are guaranteed to run of of memory (inf coerces to 2^31), so you are actually trying to allocate 9,903,520,314,283,042,199,192,993,792 bytes! 😮

 

As I said, the 3D array need to go in a shift regsiter of a loop where you replace the calculated values for the desired elements.

0 Kudos
Message 4 of 6
(2,863 Views)

OK so if I place the values through a shift register would that mean that I can only access one value at a time? The reason I need to be able to access all values is because im initializing the array to store values for a 3d graph. Would I still be able to do so?

0 Kudos
Message 5 of 6
(2,854 Views)

@sbash123 wrote:

Would I still be able to do so?


Yes

0 Kudos
Message 6 of 6
(2,845 Views)