f



??? Output argument "r" (and maybe others) not assigned during call to

So here's my problem.. this is the code i type to use euler's 2nd order to numerically integrate the following equation,

However, when i call the function with EulerMSM([0 8],0.2) in the command window,
this error returns,
Error in ==> EulerMSM>f_euler at 46
f_euler= -0.4*u - x - 0.5*x^3 +0.5*cos(0.5*t);

??? Output argument "maineqn" (and
maybe others) not assigned during
call to "c:\Program
Files\MATLAB\R2009a\Euler\EulerMSM.m>f_euler".

Error in ==> EulerMSM at 35
    a(i) = f_euler(t(i),x(i),u(i));


The full program is as below and i've tried many things to solve this.. but still could not get it.. Any help is highly appreciated

function EulerMSM(tspan,h)
% EulerMSM(dydt,tspan,y0,h):
%   uses Euler's method to integrate an ODE
% input:
%   dydt = name of the M-file that evaluates the ODE 
%   tspan = [ti, tf] where ti and tf = initial and
%           final values of independent variable
%   y0 = initial value of dependent variable
%   h = step size
% output:
%   t = vector of independent variable
%   y = vector of solution for dependent variable

ti = tspan(1)+1;
tf = tspan(2)+1;
time = (ti:h:tf);
N = length(time);
% if necessary, add an additional value of t
% so that range goes from t = ti to tf

%declaring variables
t = zeros(N+1,1);
x = zeros(N+1,1);
u = zeros(N+1,1);
a = zeros(N+1,1);
b = zeros(N+1,1);
c = zeros(N+1,1);
%initial Conditions
t(1) = 0;
x(1) = 0;
u(1) = 0;

%implement Euler's 2nd order method in for loop
for i = ti:h:tf
    a(i) = f_euler(t(i),x(i),u(i));
    t(i+1) = t_i(t(i),h);
    x(i+1) = x_i(x(i),h,u(i));
    u(i+1) = u_i(u(i),h,f_euler(i));
end

theoutput = [t x u a]


%the main function to be solved
function maineqn = f_euler(t,x,u)
f_euler= -0.4*u - x - 0.5*x^3 +0.5*cos(0.5*t);

%discretized equation below
function t = t_i(t,h)
t_i = t + h;

function x = x_i(x,h,u)
x_i = x + h*u;

function u = u_i(u,h,f)
u_i = u + h * f;
0
5/8/2012 3:13:07 AM
comp.soft-sys.matlab 211264 articles. 26 followers. lunamoonmoon (257) is leader. Post Follow

8 Replies
6418 Views

Similar Articles

[PageSpeed] 20

On 5/7/2012 10:13 PM, Clement Tham wrote:

>
>
> The full program is as below and i've tried many things to solve this..
>but still could not get it.. Any help is highly appreciated

did you try using the DEBUGGER and set break point on error?

the debugger will stop at the line where the error is.

Then all what you have to do, is just look at the line, and
examine the variables and read the error message to see
what the problem is. This is called debugging.

hth

--Nasser
0
Nasser
5/8/2012 3:18:20 AM
and on highlighting the maineqn,
this message came up

MCC requires the program to assign a value to output argument
1
5/8/2012 3:20:08 AM
"Nasser M. Abbasi" <nma@12000.org> wrote in message <joa39s$3a5$1@speranza.aioe.org>...
> On 5/7/2012 10:13 PM, Clement Tham wrote:
> 
> >
> >
> > The full program is as below and i've tried many things to solve this..
> >but still could not get it.. Any help is highly appreciated
> 
> did you try using the DEBUGGER and set break point on error?
> 
> the debugger will stop at the line where the error is.
> 
> Then all what you have to do, is just look at the line, and
> examine the variables and read the error message to see
> what the problem is. This is called debugging.
> 
> hth
> 
> --Nasser

have tried that.

my initial conditions for t=u=x=0;

and the f_euler shows the answer as 0.500 which is correct
then it exits with the error.

what could be the problem?

Thank you
0
5/8/2012 3:24:08 AM
>
> what could be the problem?
>
> Thank you

Looking at the code:

function EulerMSM(tspan,h)
% EulerMSM(dydt,tspan,y0,h):
%   uses Euler's method to integrate an ODE
% input:
%   dydt = name of the M-file that evaluates the ODE
%   tspan = [ti, tf] where ti and tf = initial and
%           final values of independent variable
%   y0 = initial value of dependent variable
%   h = step size
% output:
%   t = vector of independent variable
%   y = vector of solution for dependent variable

you did NOT return back t and y

dont you need it to be like this:

function [t,y] = EulerMSM(tspan,h)

?

--Nasser
0
Nasser
5/8/2012 3:35:43 AM
"Nasser M. Abbasi" <nma@12000.org> wrote in message <joa4af$558$1@speranza.aioe.org>...
> >
> > what could be the problem?
> >
> > Thank you
> 
> Looking at the code:
> 
> function EulerMSM(tspan,h)
> % EulerMSM(dydt,tspan,y0,h):
> %   uses Euler's method to integrate an ODE
> % input:
> %   dydt = name of the M-file that evaluates the ODE
> %   tspan = [ti, tf] where ti and tf = initial and
> %           final values of independent variable
> %   y0 = initial value of dependent variable
> %   h = step size
> % output:
> %   t = vector of independent variable
> %   y = vector of solution for dependent variable
> 
> you did NOT return back t and y
> 
> dont you need it to be like this:
> 
> function [t,y] = EulerMSM(tspan,h)
> 
> ?
> 
> --Nasser

Sorry, am new to matlab. didnt know that it should be function [t,y]

i found out something, when calling the function
t(i+1) = t_i(t(i),h);

where t_i = t + h;
after the action, the t(i) is not updated with the new value which should be t(1)=0 t(2)=0.2

what was my mistake?
0
5/8/2012 3:55:05 AM
Argh! i think i know my mistake

function x = x_i(x,h,u)
x_i = x + h*u;
end

should be 

function x = x_i(x,h,u)
x = x + h*u;
end

whole night cant sleep because of this silly mistake
0
5/8/2012 4:35:07 AM
On 5/7/2012 11:35 PM, Clement Tham wrote:
> Argh! i think i know my mistake
>
> function x = x_i(x,h,u)
> x_i = x + h*u;
> end
>
> should be
>
> function x = x_i(x,h,u)
> x = x + h*u;
> end
>
> whole night cant sleep because of this silly mistake

Well, when I face a strange problem that I do not
understand because it sits inside complicated
code, I try to reproduce the problem on the side, using
the most simple code structure possible by removing all
needed layers and peripheral code.

Almost always, I find the problem that way, because things
now become clear when all the clutter was removed.

--Nasser
0
Nasser
5/8/2012 5:01:01 AM
> Well, when I face a strange problem that I do not
> understand because it sits inside complicated
> code, I try to reproduce the problem on the side, using
> the most simple code structure possible by removing all
> needed layers and peripheral code.
> 
> Almost always, I find the problem that way, because things
> now become clear when all the clutter was removed.
> 
> --Nasser

Thanks for the advice. will keep it in mind.. still lots to learn from matlab..
0
5/8/2012 5:23:07 AM
Reply:

Similar Artilces:

??? Output argument "r" (and maybe others) not assigned during call to "/home/mat/nonlinear_g.m>nonlinear_g".
Hi, I have been writing a code to solve a nonlinear system of waves and I am using the Newton -Raphson method to solve the system. I have a main program which computes the Jacobian and solves the linar system and I have a function which I discretise my system of equations. I get an odd error of: ??? Output argument "r" (and maybe others) not assigned during call to "/home/mat/nonlinear_g.m>nonlinear_g". My function that I have written is: function r=nonlinear_g(s,p,L,n,W) X=W(1:L); Y=W(L+1:2*L); u=W(2*L+1:3*L); v=W(3*L+1:4*L); E_x=W(4*L+1:5*L); E_y=W(5*L+1...

error " Output argument "rate_match_output1" (and maybe others) not assigned during call to "C:\Users\USER\Documents\MATLAB\new_work\turbo1.m>turbo1".
my code is function [ Z_TOT,Z_TOT_INTR,rate_match_output,rate_match_output1,F] = turbo1( SEG_BLOCKS ) global c_min global c_max global k_min global k_max global block_size global filler_bits global F1 global F2 persistent rate1 persistent rate2 %% matrix of k from aseel code load turbo_intr %% calculation of f2 matrix load turbo_intr_2 %% matrix of f1 load turbo_intr_1 %i am trying to seperate blocks from SEG_BLOCKS MIN_BLOCKS=SEG_BLOCKS(1,(c_max*block_size(1)+1):end); for t=1:c_min N1=block_size(c_max+1); c1=MIN_BLOCKS(1,((t-1)*N1+1:(t*N1))); x_k1=c1; %% encode the message m1=0; % initial content of memory register equal zero m2=0; p=0; m3=0; z1=zeros(1,N1); for i=1:N1 % For N input bits b = xor(c1(i),m2); d = xor(b,m1); z1(i)=xor(d,p); m2=xor(m3,p); p=m3; m3=m1; % Content of memory register m1 shifting to m3 m1=b; end z1_tot(1,((t-1)*N1+1:(t*N1)))=z1; % the total output after encoder %% choose the value of f1 & f2 k1 = k_min; G=find(k1==turbo_intr); f1_value =turbo_intr_1(G); f2_value=turbo_intr_2(G); %% matrix after interleaver c_intr=zeros(1,N1); x=zeros(1,N1); for s=1:N1 x(s)=mod((f1_value*s + f2_value*(s^2)),k1 ); if x(s)==0 x(s)=s; end c_intr(s)=c1(x(s)); end ...

Error in get_Prefix (line 4) maskTmp = zeros(1,4); Output argument "prefix" (and maybe others) not assigned during call to "C:\Users\Suraj\Desktop\subfolder\get_Prefix.m>get_Prefix". Error in pr
function [prefix] = get_Prefix(inputIP,mask) maskTmp = zeros(1,4); for i=1:4 if mask >= 8 maskTmp(i) = 255; mask = mask-8; elseif mask ==0 maskTmp(i) = 0; else tmp=zeros(1,8); tmp(1:mask)=1; maskTmp(i) = sum(tmp.*2.^(numel(tmp)-1:-1:0)); mask=0; end end mask=maskTmp; numIP= convert_IP(inputIP); if numIP ~=-1 prefix = bitand(numIP,mask); prefix = convert_IP(prefix); end end ...

Function : Output argument "out" (and maybe others) not assigned during call to
My Principal function : function [out] = Cf( t,x ) LAMBDA=0; %constante de décroissance du soluté b=10^-3; %demi-largeur de la fente Dm=10^-10; %%coefficient de diffusion dans la matrice Vf=10^-5; %%vitesse d'advection dans la fente Xc=10^-1; %%profondeur de fracture Tc=Xc/Vf; %%temps advectif correspondant à la profondeur de fracture Zc=sqrt(Dm*Tc); %%longueur de diffusion dans la matrice %%nombres adimensionnels beta=b/Zc; %ZETA=z/Zc; T=1; %%temps final adimensionné par Tc nt=50; dt=T/nt; t=[0:dt:nt*dt]; X=1; nx=100; dx=X/nx; x=[0:dx:nx*dx]; ...

??? Error using ==> feval Output argument "x" (and maybe others) not assigned during call to
my function function [GCPV] = GCPV(Parray_stc,Htilt,fdirt,fmm,npv_inv,n_inv,ftemp) for i = 1:40 mod_code =i for j = 1:40 inv_code =j end end mod_database = xlsread('LIST_OF_MODULES.xls') inv_database = xlsread('LIST_OF_INVERTERS.xls') Pmodule_stc = mod_database(mod_code,3) Voc_stc = mod_database(mod_code,4) Vmp_stc = mod_database(mod_code,5) Isc_stc = mod_database(mod_code,6) Impp = mod_database(mod_code,7) fmm = mod_database(mod_code,8) Yvoc = mod_database(mod_code,9) Yvmp = mod_database(mod_code,10) ...

[Q] How to escape "\a" "\b" "\c" "\f" "\n" "\r" "\t" "\v" in the string output?
Hi, there. Belows are some example strings which stand for M$ Windows directory path. How can I escape the special meanings like "\a", "\n", "\r" in these M$ Windows directory name strings? C:\amail\dir1\nbar C:\bmail\dir2\tbar C:\cmail\dir3\afoo C:\fmail\dir4\vfoo C:\nmail\dir5\fbar C:\rmail\dir6\abar C:\tmail\dir7\vfoo C:\vmail\dir8\cfoo Thanks in advance. In article <1161145522.072002.20370@m7g2000cwm.googlegroups.com>, "yh" <y.hosang@gmail.com> wrote: > Hi, there. > > Belows are some example strings which stand for M$ Wi...

How do fix: "Wrong number of arguments" / "invalid propert assignment" / "Invalid argument"
I'm trying to view a web page. IE tells me there are (Java?) errors on the page. Here they are: Line: 15 Char: 7 Error: Wrong number of arguments or invalid propert assignment Code: 0 URL: http://(address.of.my.webcam):port/LiveView.html and Line: 46 Char: 3 Error: Invalid argument Code: 0 URL: http://(address.of.my.webcam):port/LiveView.html When it says "line 15" or "line 46" , is that really the 15'th and 46'th line of "liveview.html" ??? What is "Char" referring to? Here is the contents...

One or more output arguments not assigned during call to "varargout".
I googled this error message and can not even find one that exactly match the whole sentence, am I the only person who get the error? I use Matlab 2015b to run a simulation, and I got this error message randomly during 1 of multiple same simulations. My function is like the following: [varargout] = function MyFunction(var1, var2, varargin) output1 = [xxx]; output2 = [xxx]; output3 = [xxx]; ... varargout{1} = output1; if nvargin > 2 varargout{1} = output2, varargout{2} = output3; end end I got the following error: One or more output argument...

One or more output arguments not assigned during call to "movie"
Hello Matlab-world! I have this code ... figure(schleife); surf(bildgerastert) % surf(bild) colormap(gray) view(0,90) daspect([1 1 1]) xlabel('z-Achse'); ylabel('y-Achse'); grid off F(schleife) = getframe(gcf); saveas(schleife, strcat('J:\STICK\CODE\tomo\d_', int2str(schleife)), 'jpg'); close(figure(schleife)) toc end; % Schleife movie(F,5) movie2avi(movie(F),'tomo.mov') End in the end i get this error. ??? Error using ==> movie One or more output arguments not assigned during call to "movie". Could somebody help me please? Perhaps yo...

One or more output arguments not assigned during call to "set".
Hi I am using the following code to make some Radiobuttons mutually exclusive function radio_tilescan_callback(source,eventdata); val = get(source,'Value'); p = set(hRadioCellStack,'Value',abs(1-val)); end However, when I click the button to which this function is assigned as a callback I get the error: One or more output arguments not assigned during call to "set". When I remove the 'p =' there is no error message and val = 1 is displayed in the command window, However I would like to avoid having output b...

solution to ""ERROR: Output argument 'a' was not assigned during call to 'xlim'": Link to download xlim.m/ylim.m is not updated
Hi, I found technical solution to download new fixed xlim.m/ylim.m files in this adress: http://www.mathworks.com/support/solutions/en/data/1-19WWP/index.html?product=CO&solution=1-19WWP However they refering to a link to get the fixed files - but the link is not available any more. Do you know where I can download those files from? Thanks, Gilad "Gilad Asseraf" <gilad_asseraf@amat.com> wrote in message news:hsr9v6$333$1@fred.mathworks.com... > Hi, > I found technical solution to download new fixed xlim.m/ylim.m files in > this adress: &g...

One or more output arguments not assigned during call to "set". #2
i am doing image compression using LZW coding and i have got error like this Error in ==> imagecompr at 23 vector=set(0,'recursionlimit',2000); the error is present at while converting normalimage to lzw I1=rgb2gray(x); vector=set(0,'recursionlimit',2000); [vector, lzwTable] = norm2lzw(I1) if u find solution, please post the answer or the method On 10/18/2015 6:42 AM, chery/siddu wrote: > i am doing image compression using LZW coding and > i have got error like this Error in ==> imagecompr at 23 > vector=set(0,'recursionlimit',2000); &...

Error" "he output arguments of the returned function not assigned"
Hello, I have been experiencing the following error when I return multiple arguments from a program that the output arguments of the returned function not assigned during the call to the program. All the output arguments are calculated within the function properly. I believe this is a simple mistake but I cannot see it. Why am I getting this error? Thank you. Cem The Error ------------------------------------------- tTestN ('CTestasc',2) ??? Output argument "a" (and maybe others) not assigned during call to "C:\tTestN.m (tTestN)". Error ...

""""""""""""""""""""""ADD ME""""""""""""""""""""
Hi , Hope you are doing great. Please let me take this opportunity to introduce myself, Iam Karthik working with BhanInfo Inc, a NY based company. We have consultants on our bench on various technologies, my request is to add me to your distribution list and kindly do send me the requirements. i have the below list available 1. Mainframe 2. Java 3.. Financial Analyst 4. Data Architect If there is any vendor ship agreement which has to be signed then I would like to take an opportunity to represent my company and expect your cooperation... We look forward to build a ve...

"""""""""ADD ME""""""""""
Hi , Hope you are doing great. Please let me take this opportunity to introduce myself, Iam Karthik working with BhanInfoi Inc, a NY based company. We have consultants on our bench on various technologies, my request is to add me to your distribution list and kindly do send me the requirements. i have the below list available 1. Mainframe 2. Java 3.. Financial Analyst 4. Data Architect If there is any vendor ship agreement which has to be signed then I would like to take an opportunity to represent my company and expect your cooperation... ...

What does r"""any text""" mean ?
.... as you can find in os.py at line 1 ? Regards Alexander Alexander Eisenhuth wrote: > ... as you can find in os.py at line 1 ? Please don't split your request between subject and body. String literals enclosed in triple quotes are multiline strings. String literals prefixed by "r" are raw strings. http://docs.python.org/ref/strings.html Regards, Bj�rn -- BOFH excuse #71: The file system is full of it Hi Alexander, Alexander Eisenhuth wrote: > ... as you can find in os.py at line 1 ? This is a raw string. Raw strings don't interpret the escape sequences...

Urgent Requirement in """""""""""""NEW YORK""""""""""""""""
Hello Partners, Please find the requirement below. Please send the updated resume along with rate and contact no. REQ#1: Title : Java Developer ( Rating Project) Duration : 6 months Rate : open Location : NY strong java, WebLogic 9.2, Web Services, Oracle REQ#2: Title : Java Developer Duration : 4 months Rate : open Location : NY Strong java, SQL REQ#3: Title : VB.Net Consultant Location : NY Duration : 4 months Rate : open Primarily looking at someone who has Excel, VB.net a...

output argument "what ever"is not assigned
Hi, I have a little matlab problem. When I try to run my function I get following error: output argument "gridLd" is not assigned Does anyone sees the error? May function-codes is: function [cycleLd, cycleRd, cycleDk, cycleSoi, cycleMpi, cycleAgr]=ecu(cycleRpm, cycleTorque, rpm, torque, ldGrid, rdGrid, dkGrid, soiGrid, mpiGrid, agrGrid) lengthTorque=length(torque); lengthRpm=length(rpm); cycleLd = zeros(1,length(cycleLength)); cycleRd = cycleLd; cycleDk = cycleLd; cycleSoi = cycleLd; cycleMpi = cycleLd; cycleAgr = cycleLd; for i = 1:cycleLength [...

"out" and "in out"
Hi i found the following explaination: In Ada, "in" parameters are similar to C++ const parameters. They are effectively read-only within the scope of the called subprogram. Ada "in out" parameters have a reliable initial value (that passed in from the calling subprogram) and may be modified within the scope of the called procedure. Ada "out" parameters have no reliable initial value, but are expected to be assigned a value within the called procedure. What does "have no reliable initial value" mean when considering the "out" parameter? By c...

"my" and "our"
Hi, while testing a program, I erroneously declared the same variable twice within a block, the first time with "my", the second time with "our": { my $fz = 'VTX_Link'; .... ( around 200 lines of code, all in the same block) our $fz = 'VTX_Linkset'; ... } So the initial contents of the $fz declared with "my" is lost, because "our" creates a lexical alias for the global $fz, thus overwriting the previous "my" declaration. It was my error, no question. But I wonder why Perl doesn't mention this - even with "use s...

"or" and "and"
Hi, I'm just getting to discover ruby, but I find it very nice programming language. I just still don't understand how the "or" and "and" in ruby... I was playing with ruby and for example made a def to print Stem and Leaf plot (for those who didn't have a statistics course or slept on it, e.g. http://cnx.org/content/m10157/latest/) Here is the Beta version of it: class Array def n ; self.size ; end def stem_and_leaf(st = 1) # if st != (2 or 5 or 10) then ; st = 1 ; end k = Hash.new(0) self.each {|x| k[x.to_f] += 1 } k = k.sort{|a, b| a[0].to_f <=&g...

about "++" and "--"
why this program snippet display "8,7,7,8,-7,-8" the program is: main() { int i=8; printf("%d\n%d\n%d\n%d\n%d\n%d\n",++i,--i,i++,i--,-i++,-i--); } > why this program snippet display "8,7,7,8,-7,-8" Ask your compiler-vendor because this result is IMHO implementation-defined. Check this out: http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.15 http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.16 Regards, Irina Marudina fxc123@gmail.com wrote: > why this program snippet display "8,7,7,8,-7,-8&q...

"/a" is not "/a" ?
Hi everybody, while testing a module today I stumbled on something that I can work around but I don't quite understand. >>> a = "a" >>> b = "a" >>> a == b True >>> a is b True >>> c = "/a" >>> d = "/a" >>> c == d True # all good so far >>> c is d False # eeeeek! Why c and d point to two different objects with an identical string content rather than the same object? Manu Emanuele D'Arrigo wrote: >>>> c = "/a" >>>&...

"If then; if then;" and "If then; if;"
I have a raw data set which is a hierarchical file: H 321 s. main st P Mary E 21 F P william m 23 M P Susan K 3 F H 324 S. Main St I use the folowing code to read the data to creat one observation per detail(P) record including hearder record(H): data test; infile 'C:\Documents and Settings\retain.txt'; retain Address; input type $1. @; if type='H' then input @3 Address $12.; if type='P' then input @3 Name $10. @13 Age 3. @16 Gender $1.; run; but the output is not what I want: 1 321 s. main H 2 321 s. main P Mary E 21 F 3 321 s...