Error using plot Data must be numeric, datetime, duration or an array convertible to double.
6 views (last 30 days)
Show older comments
Commented: Mary Enloe on 8 Feb 2022
>> clear all
>> close all
>> syms s
>> F = (2*s+1)/(s^3 +3*s^2+4*s+2)
(2*s + 1)/(s^3 + 3*s^2 + 4*s + 2)
>> t = [0:0.1:200];
>> f = ilaplace(F)
exp(-t)*(cos(t) + 2*sin(t)) - exp(-t)
Error using plot
Data must be numeric, datetime, duration or an array
convertible to double.
I'm getting an error for my code and my teacher isn't sure what the issue is. I am able to plot smaller parts of this function but not the whole this. From what I understand from other posts it seems like the issue may be a symbolic variable or how this is defined? Any answers?
Abolfazl Chaman Motlagh on 8 Feb 2022
f is a symbolic expression not a function or vector. you can create a function with this expression, then plot the value of function on your desired points:
syms s t;
F = (2*s+1)/(s^3 +3*s^2+4*s+2);
f = ilaplace(F); %symbolic expression
f = symfun(f,t); %symbolic function with f as it's expression and t as it's input
t = [0:0.1:200];
plot(t,f(t)) % you need to put all t in argument of f cause now it is a function
% f = f(t);
More Answers (1)
Walter Roberson on 8 Feb 2022
syms s T
F = (2*s+1)/(s^3 +3*s^2+4*s+2)
t = 0:0.1:200;
f = ilaplace(F, s, T)
y = double(subs(f, T, t));
fplot(f, [0 100], 'meshdensity', 27)
The default meshdensity is 23. If you do not use the option with at least 27 you will get the wrong plot. 26 will get a plot that almost looks right unless you change the ylim.
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!