Plotting multiple functions getting an error

2 vues (au cours des 30 derniers jours)
Connor LeClaire
Connor LeClaire le 16 Jan 2022
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.

Réponses (1)

Image Analyst
Image Analyst le 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 commentaire
Connor LeClaire
Connor LeClaire le 16 Jan 2022
Modifié(e) : Connor LeClaire le 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].

Connectez-vous pour commenter.

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by