Plotting multiple functions getting an error

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

Answers (1)

Image Analyst
Image Analyst on 16 Jan 2022
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 Comment
Connor LeClaire
Connor LeClaire on 16 Jan 2022
Edited: Connor LeClaire on 16 Jan 2022
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].

Sign in to comment.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!