NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
sbash123
Posts: 22
0 Kudos

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
altenbach
Posts: 22,780
0 Kudos

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
sbash123
Posts: 22
0 Kudos

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
altenbach
Posts: 22,780
0 Kudos

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! :smileysurprised:

 

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
sbash123
Posts: 22
0 Kudos

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
altenbach
Posts: 22,780
0 Kudos

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 .

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page