Error using input Unrecognized function or variable 't'.
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Nguyen Tien Dung
am 27 Jun. 2020
Beantwortet: Walter Roberson
am 27 Jun. 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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 27 Jun. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Conversion Between Symbolic and Numeric finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!