Error using plot Data must be numeric, datetime, duration or an array convertible to double.

10 visualizaciones (últimos 30 días)
>> clear all
>> close all
>> syms s
>> F = (2*s+1)/(s^3 +3*s^2+4*s+2)
F =
(2*s + 1)/(s^3 + 3*s^2 + 4*s + 2)
>> t = [0:0.1:200];
>> f = ilaplace(F)
f =
exp(-t)*(cos(t) + 2*sin(t)) - exp(-t)
>> plot(t,f)
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?

Respuesta aceptada

Abolfazl Chaman Motlagh
Abolfazl Chaman Motlagh el 8 de Feb. de 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
% Or
% f = f(t);
% plot(t,f);

Más respuestas (1)

Walter Roberson
Walter Roberson el 8 de Feb. de 2022
syms s T
F = (2*s+1)/(s^3 +3*s^2+4*s+2)
F = 
t = 0:0.1:200;
f = ilaplace(F, s, T)
f = 
y = double(subs(f, T, t));
plot(t, y)
title('0:0.1:200')
%or
figure
fplot(f, [0 100], 'meshdensity', 27)
title('fplot[0,10]')
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.

Community Treasure Hunt

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

Start Hunting!

Translated by