In other words, I would like exp1 to perform calculations on the array of numbers t but I would like x to hold onto the symbolic value of t to be put through a Fourier Series later on. Thanks
How do I assign a symbolic variable only to change the variable to an array?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Eric Cheatwood
il 23 Ott 2017
Commentato: Walter Roberson
il 24 Ott 2017
Hi, I am having a hard time trying to assign a symbolic variable to the input x. I am wanting to use x later in my code in its symbolic form but at exp1 I would like to assign the variable a value of an array. Any help is greatly appreciated.
% code
%Prompting for Amplitude and Limits of Interest
prompt = {'Enter the Value, "A", from the form A*exp(t). Include Negative Sign if Applicable',...
'Enter the Numerical Lower Limit Over Which to Plot the Function Segment'...
'Enter the Numerical Upper Limit Over Which to Plot the Function Segment'};
prompttitle = 'Information Input';
defaultans = {'1', '0', '4'};
answer = inputdlg(prompt, prompttitle, 1, defaultans);
expamp2 = str2double(answer(1,1));
explow1 = str2double(answer(2,1));
exphigh1 = str2double(answer(3,1));
%Defining Lower and Upper Limits Chosen in Each Iteration
lowerlimit1 = explow1;
upperlimit1 = exphigh1;
Syms t
%Decay Constant Prompt
prompt1 = 'Enter the Decay Constant Using the variable "/*t" and Include Positive or Negative Integers : ';
%Prompt User to input the decay constant. This was left as a
%command window input so that maximum variations can be inputted.
x = input(prompt1);
%Auto-Defining 'To' Based on Limit Selection
To = abs(exphigh1 - explow1);
Tolong = To*100;
%Defining Horizontal Axis
t = (explow1:.01:exphigh1);
%Formatting all variable to final exp form.
exp1=expamp2*exp(x);
%Generalizing naming convention for subplots
amplitude1 = exp1;
t1 = t;
clc
Risposta accettata
Walter Roberson
il 23 Ott 2017
Something like,
syms x
X = input(prompt1);
exp1 = subs(expamp2 * exp(x), x, X);
5 Commenti
Walter Roberson
il 24 Ott 2017
Yes, it is clearer if the variable being substituted for is specified; I myself got confused when I made the above remark.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Assumptions in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!