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

3 views (last 30 days)
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.

Answers (1)

KSSV
KSSV on 24 Apr 2019
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 Comment
Steven Reif
Steven Reif on 24 Apr 2019
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.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!