Matlab script error 1050

Hi All,
I am using MATLAB Script in LabVIEW. But there is error 1050. 
Could you take my attached script and figure it out for me? Thanks a lot!
elephant
Attachments:
MATLAB SCRIPT Error.png ‏35 KB

I am also getting error 1050. The script works fine in Matlab with the same parameters. But in Labview, the following error occurs :
Error 1050 occurred at LabVIEW:  Error occurred while executing script. Error message from server: ??? Error using ==> mtimes
Inner matrix dimensions must agree.
Error in ==> linspace at 22
y = [d1+(0:n-2)*(d2-d1)/(floor(n)-1) d2];
. in wgm_Individual_RootSearch.vi
The script is:-
format longEng
[Lre Lim]=meshgrid(lambda0_re,lambda0_im);
row=0;
col=0;
R_=zeros(N1,N2);kco=zeros(N1,N2);kc=zeros(N1,N2);M1=zeros(N1,N2);M2=zeros(N1,N2);
mn=1e5;%minimum value
while(mn>tol)
L=Lre+1i*Lim;%L becomes a 2D mesh with all possible combinations of real and imag
 kco=(2*pi./L)*nco;
        kc=(2*pi./L)*nc;
        M1=nco/2*(besselj(m-1,kco*p1)-besselj(m+1,kco*p1))./besselj(m,kco*p1);
        M2=nc/2*(besselh(m-1,1,kc*p1)-besselh(m+1,1,kc*p1))./besselh(m,1,kc*p1);
        R_=abs(M1./M2 -1)';
mn=min(R_();
[row col]=find(R_==mn);
Dr=lambda0_re(N1)-lambda0_re(1);
Di=lambda0_im(N2)-lambda0_im(1);
Lr=lambda0_re(row);
Li=lambda0_im(col);
lambda0_re=linspace((Lr-(Dr/20)),(Lr+(Dr/20)),N1);
lambda0_im=linspace((Li-(Di/20)),(Li+(Di/20)),N2);
[Lre Lim]=meshgrid(lambda0_re,lambda0_im);
end
r=lambda0_re(row);
c=lambda0_im(col);
Any hints will be really appreciated.. Where am I going wrong please let me know. Thanks  a lot.
The parameters are in the screenshot below:

Similar Messages

  • Error 1050 by trying to use load'filename' in matlab script node

    Hi
    I keep getting error 1050 when Labview tries to load a text file through the matlab script node.
    I've all ready checked for it on google and this forum but found nothing. I've also done this: http://digital.ni.com/public.nsf/allkb/2B3FF46C8512C4F786256CF30071BE53 and tried to use dlmread and more. 
    The thing is that  I need the matlab script node to read a txt file that Labview made from a chart with only 1 array, plot it and export a jpg image. I can't really use the 'export image' or 'get image' function in Labview cause I need the whole plotted chart (these functions only take a snap shot of it when they're run).
    This is my code that I'm using:
     data=load('file') ;
    Vpp=(data(1:2000,1));
    xsize = (1/2000);
    plot(0.0005:0.0005:1,Vpp);
    axis([0 1 -5 5]);
    print('-djpeg', 'graph.jpg');
    The usual load in matlab to load txt files and print to print the jpeg. The code works in matlab but not in labview
    And yeah, I'm using windows 7 and legal versions of matlab r2009b and Labview 2009  
    Solved!
    Go to Solution.
    Attachments:
    matlab.jpg ‏213 KB

    Yes I forgot, this is my error...  It looks like it can't read the file path, but the 'file' path is actually just a path to my c:\user\*\*\*\*.txt 
    Error 1050 occurred at LabVIEW:  Error occurred while executing script. Error message from server: ??? Error using ==> load
    Unable to read file file: No such file or directory.

  • Error 1050 with matlab script

    Hi , i'v built an vi which sampling saving and playing audio files , i've also added matlab script for data analysis.
    the script tested in matlab and in matlab works great , when im trying to use it in labview i'm getting an error while the matlab sciprt executing . "Error using griddedInterpolant ....."
    i think that the error occures whe trying execute the command : "Sigitp = interp1(clptv, clpsig, tv, 'linear'); "
    moreover i cant figure how to read the saved filed when the loop is finished.
    I cant figure out what is the problem .
    here is the vi : 
    i've also included the vi 

    Cobmetal wrote:
    Im novice to labview , and im learning a lot from NI community , thank you for your suggestion , i will go over it , and try to learn the proper way to implement such tasks in the future.
    Thank You.
    That's excellent!  I believe that if you truly understand dataflow, you will see why your solution isn't the best one.  ASK QUESTIONS IF YOU DON'T UNDERSTAND SOMETHING.  I put that in bold caps because we are here to help you understand and get better. 
    Example:
    "According to what I learned about dataflow, I think this part of my solution mentioned above can look like this.  (Upload picture.)  Does that seem right to you?"

  • Error 1050, when calling MATLAB 7.1 from LV8.0 - Function Definitions not allowed.

    I am trying to call a MATLAB M-file from LabVIEW 8.0. I keep getting Error Code 1050:
    "Error 1050 occurred at LabVIEW:  Error occurred while executing script. Error message from server: ??? Error: Function definitions are not permitted at the prompt or in scripts.
    . in rickfito.vi->impedo.vi
    Possible reason(s):
    LabVIEW:  Error occurred while executing script"
    I tried running the sample MATLAB script example on the knowledge base, and everything works fine.
    I am guessing that this error is happening because I have functions defined in the MATLAB script. But i thought this is better programming techinque. Also, the MATLAB window opens up when I start the VI.
    Is there a way around this? I really do not want to remove the function definitions on the script.
    Thx,
    Pelo...

    First, see if the Matlab Script Node is trying to open any files. If
    so, then make sure that the current Matlab directory is set to the
    directory where that file is located. The Matlab script node in LabVIEW
    does call the Matlab script server and executes the function in the
    Matlab script node through Matlab. Therefore, even though LabVIEW may
    be in the correct directory where the file is located, make sure Matlab
    is as well.
    The error may also occur if there is a disruption
    in the script server between MATLAB and LabVIEW and the connection was
    never re-established (possibly by closing MATLAB prematurely). Close
    both LabVIEW and MATLAB then relaunch them both and run the VI.
    MATLAB®
    is a registered trademark of The MathWorks, Inc. Other product and
    company names listed are trademarks and trade names of their respective
    companies.
    -Bob
    -Bob

  • Matlab syntax errors are not caught and reported when code is executed in a LabVIEW Matlab script node

    I want to be able to catch errors that occur during the execution of Matlab code in a LabVIEW Matlab script node. According to my understanding of the documentation, errors of this type should be available at the "error out" signal point on the Matlab script node. I have noticed that even deliberately generating matlab syntax errors will not produce an error output. See the attached vi for an example.
    Attachments:
    matlab.vi ‏13 KB

    I ran your example VI and the is what I got in the Error Out cluster:
    "Code 1050
    Error occured while executing script. Error message from server: ??? This is an error
    . in matlab[1].vi"
    If you are generating custom error messages in Matlab I would suggest passing them back to LabVIEW through output variables in the script node.
    Chris_Mitchell
    Product Development Engineer
    Certified LabVIEW Architect

  • Getting error when passing variable to Matlab script

    Hi
    I am using LabVIEW 2013 Version 13.0f2 (32bit) and MATLAB R2014b (Version: 8.4.0.150421) in Windows 7 Professional  Version 6.1 (Build 7601: Service Pack 1).
    I am trying to pass measured data to a matlab script to plot but I get errors.
    I have made a small program to make the problem easyer to solve and I get this error
    Error 1050 occurred at LabVIEW:  Error occurred while executing script. Error message from server: ??? Reference to a cleared variable A.
    . in MatlabTest.vi
    I tried the solution mentioned in http://digital.ni.com/public.nsf/allkb/4475BC3CEB062C9586256D750058F14B though it was intended for an older version. This gave me this error instead
    Error 1048 occurred at LabVIEW:  LabVIEW failed to get variable from the script server. Server:"??? Undefined function or variable 'num'.
    " in MatlabTest.vi
    The problem occures when I try to access the input, in other words I can have inputs to my script as long as I do not use them.
    How can I solve this?
    Attachments:
    MatlabTest.vi ‏7 KB

    Thank you so very much.
    I shold of cours have realised that that was what happened but I always use the three clearing lines (close all, clear all, clc) in the beginning of a script to make sure that no old and irrelevant data corrupts my script and did not think about when the inputs were generated.
    Again, Thank you!

  • Error produced when trying to pass variables to a Matlab script

    For some reason, LabVIEW produces an Error 1047 (Unable to pass variable to the script server) whenever I create an input variable to a Matlab code block.
    Outputs work fine (for example, connecting an output "a" to a Matlab code block that says "a=rand(50)" correctly produces a 50x50 array of random numbers that can be displayed in LabVIEW). However, creating any kind of input node, whether or not the associated variable is mentioned in the MATLAB script, brings up an error 1047.
    Any ideas what could be causing this? I'm using LabVIEW 7.0 and MATLAB 7 (R14). I've read the article
    >here and that's not the problem, and I've also updated my matscript.dll to the latest version, 7.0.0.2, which also made no difference.

    For what its worth,
    I work in a company with a lot of Matlab users, and I,m programming in Labview and Matlab.
    When I create a testrig measurement I always have to convert data into Malab format, so I used the script server a lot... exept we have a limited pool of Matlab
    licenses so my work was halted whenever the licences where gone.
    So I wrote a Write2Matlab vi.
    This vi can log data from a measurement and write it in a Matlab readable file format (Matlab6 R12).
    After logging you can append more data. It works with(Double,Single,Int32,Int16,U16,U8,String) matrix see for yourself in an example (Write2matlab_test.vi).
    Perhaps this is an alternative solution for your problem.
    Please send me a reply if you find it usefull.
    John
    Attachments:
    Write2Matlab.llb ‏1145 KB

  • Error occured while executing Matlab script

    Hello!
    I want to run a Matlab script under LabVIEW, but there is always
    a error message which says "Error occured while executing script".
    Should I install Matlab on the same computer at first? if yes, do
    I need to configure Matlab under LabVIEW?
    Thanks!
    Le

    Yes No
    Eric P. Nichols
    P.O. Box 56235
    North Pole, AK 99705

  • Permission Denied Error when calling Matlab script from LabWindows​/CVI

    Hello,
    I am reading in data from a DAQ and am writing it to a .csv file in LabWindows/CVI.  I am then sending this data to Matlab to be filtered.  I would like the filtered data to be accessed by LabWindows/CVI so that I can display it as a strip chart.  I have gotten everything to work except the writing to a file in a Matlab script that is called from LabWindows/CVI.  I am basically using the shipped example in found in the activex demo. (http://zone.ni.com/devzone/cda/epd/p/id/2994). I select the script that I want to run and each time it tries to open a file with write permissions I get a "Permission Denied" error.  This occurs when using fopen() in Matlab.  I have also tried using csvwrite() as well as dlmwrite().  Each one gives me a similar error.  The script currently does not try to do any data processing.  It just opens the file, if it is successful it then prints "hello" and then closes it.  The script works well when it is run in Matlab, just not when it is called in LabWindows/CVI.  Below is the script.  Any thoughts, comments or suggestions are greatly appreciated.  I am also open to using other approaches for sending data between Matlab and LabWindows/CVI.  Thanks in advance!!
    fclose('all');
    [file, errmsg] = fopen('out.txt', 'w');
    if(file<0)
        disp(errmsg)
    else
        fprintf(file, 'hello');
        fclose('all');
    end;
    [file, errmsg] = fopen('out.txt', 'w');
    if(file<0)    
    disp(errmsg)
    else  
     fprintf(file, 'hello');    
    fclose('all');
    end;

    I am using Windows 7.  I am running CVI as an administrator and was able to get rid of the "Permission Denied" error by going into the User Account Controls in windows and changing it to "Never Notify".  However, this did not fix the problem of Matlab not being able to write to a file when the script is run from CVI.  In the Matlab code below, It now gets in to the "else", suggesting that fopen() returns a good file handle.  After getting in to the else statement, it will not actually write to the file, nor does it create it.  However, I can make changes to the plot settings and those appear.  Everything is functional when run from Matlab but when run from CVI, things get screwy with opening the file for writing.  It handles the read well.  It seems like there would have to be some file permission errors but, in the CVI program, I open and write to the file "in.csv".  Any help is greatly appreciated.
    clear;
    fclose('all');
    t = zeros(1000);
    t = csvread('in.csv');
    for i=1:1000
        t(i) = t(i)*4;
    end;
    [file, errmsg] = fopen('out.txt', 'w');
    if(file<0)
        disp(errmsg)
    else
        fprintf(file, 'goodbye');
        for i=1:1000
            %t(i) = t(i)*3;
            fprintf(file, '%f,', t(i));
        end;
        fclose(file);
        plot(t/3, t);
        ylabel('t');
        xlabel('Time (s)');
        title('Is this really working?!?');
    end;
    Thanks,
    Chris

  • The eig() instruction in my matlab script is causing an insane object error

    I have matlab script in a vi that I want to use to calculate eigenvectors and eigenvalues of a large array. I started with a small array (3x3)and it calculated them incorrectly. However when i ran the same script in Matlab the correct values are returned. On top of that when I try and save the vi after running it I get an insane object error at FPHP+DC. I tried rewriting the vi without copying and pasting etc. but it wont go away. I then simplified the vi to simple integer addition and removed the eig()instruction and error doesn't appear anymore, so it seems that the eig() instruction is causing all of this and it isn't even giving the correct answers! Where does this leave me? I can't get the e
    igenvectors using the Labview vi because the array i will using eventually is (944x944) and the labview vi gives me an error saying I have exceeded maximum iterations. This is why I am using Matlab in the first place.
    Thanking you in advance!!
    Marion

    I had a similar error message come up in the jump from LV 7.1 to LV 8.0.  It would cause a couple of hard crashes of Labview whenever I worked with one particular VI.  I found it was related to a wizard lock control that I had created in LV7.1 using the HMI Wizard options of my DSC module.  I actually had two such loops in my original program, one behaved, the other caused problems in the upgrade of the VI to LV 8.0.
    I discovered this by creating multiple copies of the VI in LV 7.1 and deleting different block diagram elements from each and seeing which opened without error in 8.0 and which caused the problem until I finally discovered the problem piece of code.  It was really a divide and conquer technique.
    I liked how LV 7.1 HMI wizard automatically created code that I could unlock and modify as I needed.  It seems that the HMI wizard was eliminated from the DSC module of LV 8.0 and 8.2. There were several other major changes in the behavior of the DSC module from 7.1 to 8.0 which I am still trying to learn.
    If you can discover which control or what piece of code (hopefully it is only one) is causing the problem, perhaps you can delete it in the older file version, upgrade the VI, then recreate it in the newer version VI.

  • Matlab scripts that function properly when run in matlab generating errors in labview

    Hi, I'm running LabView 7.1 and trying to use some matlab scripts in my lab view script.
    The code runs fine in matlab, but when I run it in lab view I get errors as follows:
    "LabVIEW:  Error occurred while executing script. Error message from server: ??? Error using ==> mrdivide
    Matrix dimensions must agree.
    Error in ==> extract_inl_NI at 46
     in array_test.vi"
    There is no division in line 46 (in fact it's a blank line).  Are there syntax changes that I may not know?  Or perhaps a way to compile my code to ensure it runs correctly?

    Hello,
    Can you post your code (VI) here, or better yet a simplified version of it which still causes a problem.  If you can also post a simple version which functions as you expect, that would be nice, but it sounds like the plotting problem is intermittent.  This should work, per the following document, but perhaps there's an issue:
    http://digital.ni.com/public.nsf/websearch/57FE03DA9C357E9486256A0D00739CA6?OpenDocument
    Hopefully after seeing the code I will have more ideas about what may be going wrong.  As a final thought, are there any parameters to the plot function which can be passed to make it show the plot or make it the active window... could this be a very strange UI feature?  I guess it will make more sense when I see the VI(s).
    I look forward to your repost!
    Best Regards,
    JLS
    Best,
    JLS
    Sixclear

  • Why Does My MATLAB Script Return Error 1048?

    I am running Matlab 6.5, and the matlab scrip is
    M_thred2=M > Thred;
    M is 2 dimensional array and Thred is a constant, so M_thred2 will have thresholded array from M.
    If I make M as output, it works fine, but M_thred2 doesn't.

    Hi,
    This error can occur if your variable name is the same as a function name in MATLAB. For instance, using the variable name disp and then trying to return this variable will generate this error. To fix this, choose variable names that are not reserved names used by MATLAB. See the MATLAB online help or user manual for a list of reserved function names.
    This error can also be generated if the Clear All function is used in your MATLAB script. To resolve the error, simply remove this function from your script. For more information on creating and using MATLAB scripts in LabVIEW, refer to LabVIEW's VI, Function, & How-To Help.
    Hope this helps,
    Isabelle
    Ingénieur d'applications
    National Instruments France

  • Error (1046) using matlab script

    Hi ,
    im trying to use matlab script Labview , i've got matlab installed.
    when im running the VI , i'm getting an error 1046 , i tried to search the community ,
    and i've been told to check the "choose script server" , i dont know why , but i it's "grayed" ,
    and i cant change anything.

    Cobmetal,
    Looking at the following KnowledgeBase, it looks like MATLAB® may need to be registered as an ActiveX server first.
    http://digital.ni.com/public.nsf/allkb/5BECAA32D63921628625670C005BDA1A?OpenDocument
    Mathworks has good documentation about how to register MATLAB as a COM Automation server in the Windows registry when launched. I would try to do that if the option to choose script server is greyed out (Ctrl+F regserver).
    http://www.mathworks.com/help/matlab/ref/matlabwindows.html
    MATLAB® is a registered trademark of The MathWorks, Inc. Other product and company names listed are trademarks and trade names of their respective companies.
    Matt J
    Professional Googler and Kudo Addict
    National Instruments

  • Error 1048 Matlab Script depends on string length

    Using: Labview 8.2, Matlab 2007a, Windows XP (AMD X2 4200+ 3GB RAM).
    I'm having an issue with MATLAB script server, Error 1048 failed to get variable from script server.  I've read the forums, but most posts are years old and don't address variable size issues.  I have no problem with these strings inside the MATLAB command window.  I'm somewhat inexperienced with LabView, so maybe this VI could have been simplified.
    I'm writing data files with a tab header, using MATLAB to perform some operations on data (I have a library written to do certain things and can't really spend the time to recode in Labview).  When I try to pass out the new header string, I get error 1048 only when the string length goes above a certain size range.  I have iterations because I want to process hundreds of files in a similar fashion to this VI.
    Header length ~ 1300 chars has always been fine, regardless of number of iterations within the VI.
    Header length ~ 2600 chars presents some errors; not deterministic.
    Header length ~ 5200 chars has many errors; not deterministic.
    Header length ~ 7800 chars has many errors, fails almost all the time.
    Also, timing delay after reading in the file seemed to do nothing to help.  Pausing at the end of the MATLAB script did not seem to help. Clearing MATLAB/restarting LabView did not seem to help.  Is there a way to catch variable-specific errors from the script window?  Notice that the output variable is not cleared when it fails to be obtained from the MATLAB window.  I could wrap the whole thing in a while loop until there are no errors, but that doesn't help when the length is so large none of them succeed.   I can split the string inside matlab, but I'd have to create n strings and then concatenate them outside, which still gives me a lack of scalability.  Is there any better way to handle this kind of non-deterministic error?
    Thanks very much for reading.
    Attachments:
    header6001.txt ‏8 KB
    Matlab Script Server Test1.vi ‏38 KB
    header1001.txt ‏2 KB

    Does NI monitor these forums for bug reports to fix?  Here's a non-scalable hack solution I mentioned earlier, creating n string outputs and concatenating them in Labview.  I've checked this in Matlab using the code below.  I've included the VI if anyone has the same issue and wants it.
    Note that I chose to throw the size error if the string is too large for the n you choose.  I prefer this to trying to check the string output to see if it was truncated.
    hcols = size(hstring,2);
    for k = 1:8
        hvar = strcat('h', sprintf('%d',k));
        if( hcols >  k*1000 & k < 8 )
            hcom = sprintf('%s = ''%s'';', hvar, hstring(1, ((k-1)*1000+1):k*1000 ));
        %if size < k*1000, or we're at the end with leftovers, copy what's left
        elseif( hcols >= (k-1)*1000+1  &  (hcols <= k*1000 | k == 8 ))
            hcom = sprintf('%s = ''%s'';', hvar, hstring(1, ((k-1)*1000+1):end));
        else
            hcom = sprintf('%s = '''';', hvar);
        end  
        eval(hcom);
    end
    %Matlab validation code.  Do not use strcat, as it will chop tabs at the endpoints.
    newh = sprintf('%s%s%s%s%s%s%s%s', h1, h2, h3, h4, h5, h6, h7, h8);
    strcmp(hstring, newh)
    Attachments:
    Matlab Script Server Test2.vi ‏40 KB

  • How to call matlab script? (it shows server error)

    hi all
    i am using original version of Labview 8.2 and Matlab 7 . but i can not call the matlab script in Labview. while doing the same it shows server error Active X control fails to connect the server. What can i do?
    suggestion please...
    thanks in advance...

    Hi adsafsaf,
    Can you provide an error number or more details about how you are trying to call your MatLab script? Until you can share those details, you might want to consult either this KnowledgeBase or this one.
    Regards,
    Hillary E
    National Instruments

Maybe you are looking for

  • Action for ENTER KEY is not working in alv grid output (Classical)

    Hi Experts,   I have searched SDN around 8 hours and could not get any help on my below issue.   I am developing ALV report using function module (Classical ALV). ALV output has 4 input enable fields, if user enters data in any of those fields and cl

  • Continue motion tracking

    I did motion tracking and have a target layer attached to the motion tracking and it the target is masked. It is working great. I corrected some of the keyframes in the motion tracking and really fine tuned it. Now, I would like to continue the same

  • What is the home page button?

    On safari i can't find the home page button. How can I get to appear?

  • Never gotten this error message, what does it mean?

    When trying to access this link: http://einestages.spiegel.de/hund-images/original/2008/02/24/3/49cb6707b145cf399 ce7b386793af06e_orig.jpg I got this error: ERROR The requested URL could not be retrieved While trying to retrieve the URL: http://eines

  • Split  alv to 3

    Hi all. I have a screen splited to 2. I would like to split it to 3 - top, middle & bottom. My code is: * Creating Custom Container   IF g_custom_container IS INITIAL.     CREATE OBJECT g_custom_container       EXPORTING         container_name = g_cu