Error using input Unrecognized function or variable 't'.
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Nguyen Tien Dung
le 27 Juin 2020
Réponse apportée : Walter Roberson
le 27 Juin 2020
Hi everyone, can you help me fix this problem
***This is my matlab code
clear all
clc
prompt1='Her retirement increases by R1 % per year ';
prompt2='Plus R2 % of her yearsalary ';
prompt3='Time she started working ';
prompt4='Her salary S(t) increase exponentially after t years';
R1= input(prompt1);
R2= input(prompt2);
p= input(prompt3);
S= input(prompt4);
syms A(t)
ode = diff(A,t) -R1*A == R2*S;
cond = A(0) == 0;
ASol(t) = dsolve(ode,cond);
ASol(p)
***And when i put number and run
Her retirement increases by R1 % per year
0.06
Plus R2 % of her yearsalary
0.12
Time she started working
40
Her salary S(t) increase exponentially after t years
30*exp(t/20)
Error using input
Unrecognized function or variable 't'.
Error in untit5led (line 11)
S= input(prompt4);
Her salary S(t) increase exponentially after t years
***Thank you very much.
0 commentaires
Réponse acceptée
Walter Roberson
le 27 Juin 2020
S= input(prompt4);
syms A(t)
Notice you have the input(prompt4) call before you have the syms A(t) call. Because of that order, the symbolic variable t has not been defined yet, and so is not available for when the user types in 30*exp(t/20) in response to the input() prompt.
You need to move the syms line to before the S= line.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Conversion Between Symbolic and Numeric dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!