Plotting multiple functions getting an error

2 次查看(过去 30 天)
Hello,
I am trying to plot a function and a piecewise function on the same subplot but the second (piecewise) function is not plottedand I keep getting the error:
Warning: Error updating FunctionLine.
DataSpace or ColorSpace transform method failed.
%Edited for clarity
syms w real;
clc;
phase = atand(w/3)+atand(w/5)-90+atand(-w/2)+atand(-w/4); %1st equation
pPhase = piecewise(w<0.2,-90); %2nd equation (currently a test function, but full version will span 0.01→1000), must be piecewise
figure();
fplot(phase,[0.01, 1000]);
set(gca,'Xscale','log')
hold on;
fplot(pPhase);
I would like to plot both functions on the same graph.

回答(1 个)

Image Analyst
Image Analyst 2022-1-16
If you don't use syms and fplot(), you can do this:
numPoints = 2000;
w = linspace(0, 1000, numPoints);
phase = atand(w/3)+atand(w/5)-90+atand(-w/2)+atand(-w/4);
plot(w, phase, '-');
set(gca,'Xscale','log')
but what is your second function and over what range does it apply to?
  1 个评论
Connor LeClaire
Connor LeClaire 2022-1-16
编辑:Connor LeClaire 2022-1-16
It is the piecewise function 'pPhase' (3rd line from the bottom in my code). Currently just a test function, but it will apply exactly to the plotted range [0.01, 1000].

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by