Clear Filters
Clear Filters

Trying to change the y axis range in fplot

53 views (last 30 days)
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
Please help

Accepted Answer

Star Strider
Star Strider on 31 Oct 2022
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])
ylim([-1 1]) % ADDED
grid % ADDED
.

More Answers (1)

Chunru
Chunru on 31 Oct 2022
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]) %<=====================

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!