Plotting a function of a function with piecewise limits
20 ビュー (過去 30 日間)
I am trying to plot a function of a function, f(x(t)) with piecewise limits, however I keep getting an error that "Subscript indices must either be real positive integers or logicals."
Im wondeirng if I need to adjust my limits im using in my piecewise function so they are in terms of t or if I can leave it in the current form and am missing something else.
x = 2*sin(t);
%% Plot 1
f_1 = piecewise(x<-1, 1.5*x+1.5, 0, -1<x<1, 1.5*x(t)-1.5, x>1);
plot (f_1, t);
回答 (1 件)
Dana 2020 年 9 月 25 日
It's the x(t) that shows up in your definition of f_1: t is a vector of real numbers (including non-integers), so x(t) is not a sensible MATLAB expression. Did you want that to just be x rather than x(t)?