Cart | Help
 You are here: NI Home > NI Developer Zone > NI Discussion Forums Select Community English Français Italiano 日本語 한국어 Español 简体中文 繁体中文 Português (BR)

Member
Posts: 22

# 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

Knight of NI
Posts: 22,780

# Re: Matlab script I need to input into labview?

[ Edited ]

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.

LabVIEW Champion . Oh, by the way, I work for peanutsKudos .

Member
Posts: 22

# Re: Matlab script I need to input into labview?

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

Knight of NI
Posts: 22,780

# Re: Matlab script I need to input into labview?

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.

LabVIEW Champion . Oh, by the way, I work for peanutsKudos .

Member
Posts: 22

# Re: Matlab script I need to input into labview?

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?

Knight of NI
Posts: 22,780

# Re: Matlab script I need to input into labview?

sbash123 wrote:

Would I still be able to do so?

Yes

LabVIEW Champion . Oh, by the way, I work for peanutsKudos .