Trying to change the y axis range in fplot

60 次查看（过去 30 天）
Saim2022-10-31

This is the code
clear all
clc
close all
syms s a b c d e f
n10 = a + (b*s) + c*(s^2) + d*(s^3) + e*(s^4) + f*(s^5)
n10_d1 = diff(n10,s)
n10_d2 = diff(n10_d1,s)
A = subs(n10,s,-1)
B = subs(n10,s,1)
C = subs(n10_d1,s,-1)
D = subs(n10_d1,s,1)
E = subs(n10_d2,s,-1)
F = subs(n10_d2,s,1)
eqn1 = A == 0;
eqn2 = B == 0;
eqn3 = C == 1;
eqn4 = D == 0;
eqn5 = E == 0;
eqn6 = F == 0;
[G,H] = equationsToMatrix([eqn1, eqn2, eqn3, eqn4, eqn5, eqn6], [a, b, c, d, e, f])
X = linsolve(G,H)
x = [1;s;s^2;s^3;s^4;s^5]
N3 = transpose(X)*x
hold on
fplot(N3,[-1 1])
It plots automatically between y = 0 and y = 0.4
I want to plot it between y= -1 and y = +1
The purpoe is comparison with other existing graphs that are between -1<=y<=1
Running it on MATLAB online

采纳的回答

Star Strider 2022-10-31
See if ylim will do what you want —
syms s a b c d e f
n10 = a + (b*s) + c*(s^2) + d*(s^3) + e*(s^4) + f*(s^5)
n10 =
n10_d1 = diff(n10,s)
n10_d1 =
n10_d2 = diff(n10_d1,s)
n10_d2 =
A = subs(n10,s,-1)
A =
B = subs(n10,s,1)
B =
C = subs(n10_d1,s,-1)
C =
D = subs(n10_d1,s,1)
D =
E = subs(n10_d2,s,-1)
E =
F = subs(n10_d2,s,1)
F =
eqn1 = A == 0;
eqn2 = B == 0;
eqn3 = C == 1;
eqn4 = D == 0;
eqn5 = E == 0;
eqn6 = F == 0;
[G,H] = equationsToMatrix([eqn1, eqn2, eqn3, eqn4, eqn5, eqn6], [a, b, c, d, e, f])
G =
H =
X = linsolve(G,H)
X =
x = [1;s;s^2;s^3;s^4;s^5]
x =
N3 = transpose(X)*x
N3 =
% hold on
fplot(N3,[-1 1])
.
2 个评论显示 1更早的评论隐藏 1更早的评论
Star Strider 2022-10-31
As always, my pleasure!

更多回答（1 个）

Chunru 2022-10-31
syms s a b c d e f
n10 = a + (b*s) + c*(s^2) + d*(s^3) + e*(s^4) + f*(s^5)
n10 =
n10_d1 = diff(n10,s)
n10_d1 =
n10_d2 = diff(n10_d1,s)
n10_d2 =
A = subs(n10,s,-1)
A =
B = subs(n10,s,1)
B =
C = subs(n10_d1,s,-1)
C =
D = subs(n10_d1,s,1)
D =
E = subs(n10_d2,s,-1)
E =
F = subs(n10_d2,s,1)
F =
eqn1 = A == 0;
eqn2 = B == 0;
eqn3 = C == 1;
eqn4 = D == 0;
eqn5 = E == 0;
eqn6 = F == 0;
[G,H] = equationsToMatrix([eqn1, eqn2, eqn3, eqn4, eqn5, eqn6], [a, b, c, d, e, f])
G =
H =
X = linsolve(G,H)
X =
x = [1;s;s^2;s^3;s^4;s^5]
x =
N3 = transpose(X)*x
N3 =
hold on
fplot(N3,[-1 1])
ylim([-1 1]) %<=====================

类别

Find more on Formatting and Annotation in Help Center and File Exchange

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by