fplot not showing any value
4 次查看(过去 30 天)
显示 更早的评论
Hello, I'm fairly new to Matlab, and I need to plot a function. This function is the double anti-derivative of another function.
Using fplot to plot the first function works, but it doesn't show any value for the second function... Here is my code :
syms x D(x) Dint(x) g(x) f(x)
E=2.1*10^11
L=12
F=2000
K=1500
C=0.28
e=0.008
a=0.00076
P=3000
w=77008.5
% Fonctions
D(x)=0.2191-a*x
Dint(x)=D(x)-2*e
f(x)= (-F*(L-x)-K*C*(D(x))*(L-x)^2/2)/(E*3.14*(D(x)^4-Dint(x)^4)/64)
g(x)=int(f(x)) - subs(int(f(x)),x,0)
Y(x)=int(g(x)) - subs(int(g(x)),x,0)
subs(Y,x,0)
double(subs(Y,x,12))
% Debug
fplot(f,[0 12])
fplot(Y,[0 12])
I am using Matlab R2024a.
Thanks in advance !
3 个评论
采纳的回答
SAI SRUJAN
2024-5-28
Hi Samuel,
I understand that you are facing an issue trying to plot a complex-valued function.
A straightforward approach is to plot the real and imaginary parts of the function separately. We can also use 'plot3' function, this method plots the real part of the input on one axis, the imaginary part on another, and the magnitude of the output on the third axis.
Please follow the below code sample to proceed further,
Y = @(z) exp(1i*z);
% Create a figure for the Real part of Y
figure;
subplot(2, 2, 1); % Subplot 1
fplot(@(z) real(Y(z)), [0 12]);
% Create a subplot for the Imaginary part of Y
subplot(2, 2, 2); % Subplot 2
fplot(@(z) imag(Y(z)), [0 12]);
% Create a subplot for the Magnitude of Y
subplot(2, 2, 3); % Subplot 3
fplot(@(z) abs(Y(z)), [0 12]);
% Create a subplot for the Phase of Y
subplot(2, 2, 4); % Subplot 4
fplot(@(z) angle(Y(z)), [0 12]);
sgtitle('Visualization of Y(z) = e^{iz}'); % Super title for the figure
% 3D Plot using plot3
figure;
z = linspace(-2*pi, 2*pi, 1000);
plot3(real(Y(z)), imag(Y(z)), abs(Y(z)), 'LineWidth', 2);
For a comprehensive understanding of the 'plot3','fplot' and 'subplot' functions in MATLAB, please refer to the following documentation.
I hope this helps!
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!