Inverse Laplace working in command window but not in editor

1 vue (au cours des 30 derniers jours)
Tyler Luzar
Tyler Luzar le 9 Mar 2020
Hi there, I am writing a script to solve laplace and inverse laplace functions. When I call the inverse laplace function in the command window, it works fine. However, when I call it in the script itself, it does not seem to work. Anyone have any ideas? Below is my code.
Script code:
%---- Inverse Laplace Solver ----%
%------------DOESN'T WORK--------%
clear all
prompt = "What do you not want to do?:";
f = input(prompt);
syms s t
ilaplace(f)
Command window code:
>> ilaplace(1/(s-4))
ans =
exp(4*t)

Réponses (1)

Gouri Chennuru
Gouri Chennuru le 12 Mar 2020
Change the script code to
clear all
syms s t
prompt = "What do you not want to do?:";
f = input(prompt);
ilaplace(f)
f is an input to the ilaplace function and this input should be specified as a symbolic expression, symbolic function, symbolic vector or symbolic matrix.
clear all at the beginning will clear the entire workspace and before you take the input f from the user the independent variable s and Transformation variable t should be defined.
Hope this helps!

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by