lsode function in octave - octave

I wrote the code below and it worked for several weeks without any problem.
Suddenely it stoped working with following error:
"warning: lsode: passing function body as a string is obsolete; please use anonymous functions
warning: called from
heun at line 23 column 2
error: 'f' undefined near line 1 column 42
error: lsode: evaluation of user-supplied function failed
error: called from
__lsode_fcn__C__ at line 1 column 40
heun at line 23 column 2"
The code is:
function yn=euler(t0,y0,tend,f,n)
t0=input('Gib hier t0 ein:');
y0=input('Gib hier y0 ein:');
tend=input('Bis zu welchem Wert von t möchtest du y annährn?');
n=input('Gib hier die Anzahl der Schritte ein(n):');
fstrich=input('Wie lautet die Differentialgleichung?', 's');
f=inline('fstrich');
dt=(tend-t0)/n;
t(1)=t0;
y(1)=y0;
for i=1:n
t(i+1)=t(i)+dt;
y(i+1)=y(i)+f(t(i),y(i))*dt;
rotdim([flip(t) ; flip(y)])
scatter(t,y,'*')
hold on
f=inline('fstrich');
t=t0:0.001:tend;
y=lsode('f',y0,t);
plot(t,y)
Does anyone see a mistake or something I can change?

Apparently you updated octave.
f=inline('fstrich'); % this is discouraged
y=lsode('f',y0,t); % and this is not valid anymore.
Instead, make an anonymous function
f=str2func(fstrich);
y=lsode(f,y0,t);

Related

An argument to be passed on the mktime built-in function in PHP. How to pass an argument in a mktime function

Actually, I was trying to run a PHP script on a local server, but unfortuantely i encountered this error
Fatal error: Uncaught ArgumentCountError: mktime() expects at least 1 argument, 0 given in C:\xampp\htdocs\SimplePharmacy-PHP\home.php:240 Stack trace: #0 C:\xampp\htdocs\SimplePharmacy-PHP\home.php(240): mktime() #1 {main} thrown in C:\xampp\htdocs\SimplePharmacy-PHP\home.php on line 240
Below is the PHP code that I was refereed to from my source code.
<?php
$Today = date('y:m:d',mktime()); // Line 238
$new = date('l, F d, Y', strtotime($Today));// Line 239
echo $new; // Line 240
?>
I am trying to disply the current date date and year

incremental search method script errors

I wrote my very first octave script which is a code for the incremental search method for root finding but I encountered numerous errors that I found hard to understand.
The following is the script:
clear
syms x;
fct=input('enter your function in standard form: ');
f=str2func(fct); % This built in octave function creates functions from strings
Xmax=input('X maximum= ');
Xinit=input('X initial= ');
dx=input('dx= ');
epsi=input('epsi= ');
N=10; % the amount by which dx is decreased in case a root was found.
while (x<=Xmax)
f1=f(Xinit);
x=x+dx
f2=f(x);
if (abs(f2)>(1/epsi))
disp('The function approches infinity at ', num2str(x));
x=x+epsi;
else
if ((f2*f1)>0)
x=x+dx;
elseif ((f2*f1)==0)
disp('a root at ', num2str );
x=x+epsi;
else
if (dx < epsi)
disp('a root at ', num2str);
x=x+epsi;
else
x=x-dx;
dx=dx/N;
x=x+dx;
end
end
end
end
when running it the following errors showed up:
>> Incremental
enter your function in standard form: 1+(5.25*x)-(sec(sqrt(0.68*x)))
warning: passing floating-point values to sym is dangerous, see "help sym"
warning: called from
double_to_sym_heuristic at line 50 column 7
sym at line 379 column 13
mtimes at line 63 column 5
Incremental at line 3 column 4
warning: passing floating-point values to sym is dangerous, see "help sym"
warning: called from
double_to_sym_heuristic at line 50 column 7
sym at line 379 column 13
mtimes at line 63 column 5
Incremental at line 3 column 4
error: wrong type argument 'class'
error: str2func: FCN_NAME must be a string
error: called from
Incremental at line 4 column 2
Below is the flowchart of the incremental search method:
The problem happens in this line:
fct=input('enter your function in standard form: ');
Here input takes the user input and evaluates it. It tries to convert it into a number. In the next line,
f=str2func(fct)
you assume fct is a string.
To fix the problems, tell input to just return the user's input unchanged as a string (see the docs):
fct=input('enter your function in standard form: ', 's');

Custom character for input

I am new to java, I am working with primefaces and as part of a capture for username I am being asked for this.
How can I customize the capture? You can capture numbers (0-9) and letters (a-zA-Z) but I also require: # $ & -_. How can I make special characters for this? Thanks in advance and an apology in case I do not ask the question correctly.
I already made several tests but I do not have the desired result. When I put the "&" character it marks me an error leaving it like this:
<o:validator
validatorId="javax.faces.RegularExpression"
pattern="^[#$-_.A-Za-z0-9\\+]+(\\.[#$-_.A-Za-z0-9]+)*"
message="La contraseña no tiene un formato válido." />
<p:outputLabel value="Contraseña:" for="newUserPwd1"/>
<p:password
id="newUserPwd1" value="#{userManagerView.pass1}" required="true"
requiredMessage ="La contraseña es obligatoria.">
<o:validator
validatorId="javax.faces.Length" minimum="6"
message="La contraseña requiere mínimo de 6 caracteres"/>
<o:validator
validatorId="javax.faces.RegularExpression"
pattern="^[#$-_.A-Za-z0-9\\+]+(\\.[#$-_.A-Za-z0-9]+)*"
message="La contraseña no tiene un formato válido." />
</p:password>
This is the error with the character &
Parsing Error /viewMetadata/admin/usuarios.xhtml: Error Traced [line: 172] A decimal representation must appear immediately after "& #
Caused by:
javax.faces.view.facelets.FaceletException - Error Parsing /viewMetadata/admin/usuarios.xhtml: Error Traced [line: 172] A decimal representation must appear immediately after "& #
at org.apache.myfaces.view.facelets.compiler.SAXCompiler.doCompileViewMetadata (SAXCompiler.java:838)

No keyword with name 'Fetch From Left' found

I'm automating with robot framework but I'm getting this error
No keyword with name 'Fetch From Left' found.
I don't understand the cause, I'm new in this tool
Here is my code:
${FILE_RUTS_INFORMACION_PERSONAL} archivo2.csv
Im reading CSV file with three DNI
Carga RUTs
[Documentation] Carga lista de RUTs a validar desde archivo csv
[Arguments] ${file_name}
${data}= read csv file ${file_name}
[return] ${data}
Here is the error:
Consultar WS
[Documentation] Lee RUTs de archivo csv y consulta cada uno al Experto Original y Migrado.
[Arguments] ${data}
${rutsd}= Set Variable 0
${dv} = Set Variable 0
Log To Console .
:FOR ${element} IN ${data}
\ ${rutsd}= Fetch From Left #{element}[0] ;
\ ${dvymas}= Get Substring #{element}[0] -1
\ ${dv}= Fetch From Left ${dvymas} ;
\ Log To Console Consultando RUT ${rutsd}...
\ Run Keyword And Continue On Failure WS Experto Orignal ${rutsd} ${dv}
ERROR:
FOR ${element} IN [ ${data} ]
Start / End / Elapsed: 20170823 10:00:11.149 / 20170823 10:00:11.151 / 00:00:00.002
00:00:00.002VAR ${element} = [['169233xxx;'], ['169129xxx;'], ['189925xxx;']]
Start / End / Elapsed: 20170823 10:00:11.149 / 20170823 10:00:11.151 / 00:00:00.002
00:00:00.000KEYWORD ${rutsd}= = Fetch From Left #{element}[0], ;
Start / End / Elapsed: 20170823 10:00:11.151 / 20170823 10:00:11.151 / 00:00:00.000
10:00:11.151 FAIL No keyword with name 'Fetch From Left' found.
You need to import the String library. See the user guide for more information. Only the BuiltIn library doesn't need to be imported. Looking at the code you posted, you don't seem to be importing it.
Adding this to your settings section should do the trick
*** Settings ***
Library String

Error in for sentence robotframework

Hi im reading a CSV file (to get information from a WEB Service) with this values:
169233xxx
169129xxx
189925xxx
This is my keyword definition:
Carga RUTs
[Documentation] Carga lista de RUTs a validar desde archivo csv
[Arguments] ${file_name}
${data}= read csv file ${file_name}
[return] ${data}
I catch this values in a for:
Consultar WS
[Documentation] Lee RUTs de archivo csv y consulta cada uno al Experto Original y Migrado.
[Arguments] ${data}
${rutsd}= Set Variable 0
Log To Console .
:FOR ${element} IN #{data}
\ ${rutsd}= Fetch From Left ${element}[0] ;
\ ${dvymas}= Get Substring ${element}[0] -2
\ Log To Console Consultando RUT ${rutsd}...
\ Run Keyword And Continue On Failure WS Experto Orignal ${rutsd}
At the moment of consulting....Appears for each "[" or "$apos" icon , i dont understand
<ns1:rut>['189925xxx </ns1:rut>
<ns1:rut>[$apos 189925xxx </ns1:rut>
At finally response:
Server raised fault: '1001: RUT no Válido' (translate DNI invalid(
Can someone explain to me why I am getting this error?
Thanks,
Regards!!
EDIT:
To not creat a new post i have a new error, i modified
${element}[0] for #{element}[0]
The previous error was solved.
Now i have a new error:
List variable '#{element}' has no item in index 0
Can someone explain to me why I am getting this error?
thanks again