Getting Error: Data must be numeric, datetime, duration or an array convertible to double.

As a preface I lack a clear understanding of Matlab.
Here is my code:
%% Case 2) Non-Homogenous
close all;clear;clc
t=linspace(0,1,10);
i11=exp(0.5*t).*(cosh(sqrt(14.75)*t)-(3.5/sqrt(14.75))*sinh(sqrt(14.75)*t));
i12=(exp(0.5*t)/sqrt(14.75)).*sinh(sqrt(14.75)*t);
i21=(3*exp(0.5*t)/sqrt(14.75)).*sinh(sqrt(14.75)*t);
i22=(exp(0.5*t)).*(cosh(sqrt(14.75)*t)+(3.5/sqrt(14.75))*sinh(sqrt(14.75)*t));
M1=[i11 i12;i21 i22];
x0=[2;1];
p1=M1.*x0;
%% Symbolic Integration Examples (Problem 2)
syms tau
j11=exp(0.5*(t-tau)).*(cosh(sqrt(14.75)*(t-tau))-(3.5/sqrt(14.75))*sinh(sqrt(14.75)*(t-tau)));
j12=(exp(0.5*(t-tau))/sqrt(14.75)).*sinh(sqrt(14.75)*(t-tau));
j21=(3*exp(0.5*(t-tau))/sqrt(14.75)).*sinh(sqrt(14.75)*(t-tau));
j22=(exp(0.5*(t-tau))).*(cosh(sqrt(14.75)*(t-tau))+(3.5/sqrt(14.75))*sinh(sqrt(14.75)*(t-tau)));
p11=int(j11,tau);
p12=int(j12,tau);
p21=int(j21,tau);
p22=int(j22,tau);
M2=[p11 p12;p21 p22];
b=[4;2];
p2=M2.*b;
%%
x=p1+p2;
y=([1 2]*x)+6;
plot(t,y)
Any help provided is much appreciated.

回答(1 个)

YOu see t is double and y is of class sym. y has variable tau YOu have two options.
  1. Convert y into double by substituting possilbe values of tau using subs and double; and use plot.
  2. Or use ezplot or fplot.

1 个评论

I have spent awhile googling subs and double and am not seeing a clear path into utilizing these commands. If you could elaborate further I woul be immensly grateful. In reguards to your suggestion of ezplot or fplot simply changing my plot command does not work. I also tried using a syms for both t and tau rather than calling out a linspace for t.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Mathematics 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by