For Programmers: Free Programming Magazines  


Home > Archive > Matlab > April 2005 > Matlab Funtion Outputs









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Matlab Funtion Outputs
Andy Pilkington

2005-04-27, 9:01 pm

I am creating a function that needs to have two ouputs but I can only
get it to output one or the other and not both at the same time. Here
is the function

function [ljError ljValue] = ljud_eGet(ljHandle, IOType, Channel,
ljValue, x1);
[ljError ljValue] =
calllib('labjackud','eGet',ljHandle,IOTy
pe,Channel,ljValue,x1);

with the mfile as above I get "ans = 0", which is correct for the
ljError value. If I change the first part of the function to read
"function [ljValue] = ......" then I get "ans = 4.67" which is also
correct.

How can I change my function so that if outputs both? The preferred
output would be "ans = 0 ans = 4.67".

Also, I intend to call this function from other mfiles. Right now I
call it by writing:

AIN0 = ljud_eGet(ljHandle,10,0,0,0);

Is there a way to call the function from an mfile so that it places
both function outputs into variables in the current mfile? Maybe
somethinglike the following:

[Error AIN0] = ljud_eGet(ljHandle,10,0,0,0);

Thanks in advance for your help.
us

2005-04-27, 9:01 pm

Andy Pilkington:
<SNIP slight confusion of a ML newcomer...

created a func with two output args and wants to see both

AIN0=afunc(someargs);
% wrong
[Error,AIN0]=afunc(someargs);
% right

us
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com