Error Using Plot for single variable function

I am trying to plot the function Rv(f) and then theta(f). However, whenever I run it I get "Error using plot
Data must be numeric, datetime, duration or an array convertible to double."
Any help would be appreciated.
syms f
% Physical properties of the bar
V0 = 1;
R = 1000;
L = 470*10^(-6);
C = 120*10^(-12);
Rv(f) = (V0*R)/sqrt(R^(2)+(2*pi*f*L-1/(2*pi*f*C))^(2));
theta(f) = atan(((1/(2*pi*f*C))-2*pi*f*L)/R);
x1 = 0:1000:4000000;
% Calculate the inital distribution (almost)
plot(x1,Rv(f))
xlabel('x');
grid on
grid minor
pause(0.01)

2 commentaires

KSSV
KSSV le 28 Avr 2020
Youcannot use Rv(f) which is a function striaght away in plot. Substitute the values of f using subs and plot.
could you show how to use subs in this case. not quite getting it still. I'm trying
subs(Rv,f,x1);

Connectez-vous pour commenter.

 Réponse acceptée

Ameer Hamza
Ameer Hamza le 28 Avr 2020
Modifié(e) : Ameer Hamza le 28 Avr 2020
There are two ways.
1. use fplot
syms f
% Physical properties of the bar
V0 = 1;
R = 1000;
L = 470*10^(-6);
C = 120*10^(-12);
Rv(f) = (V0*R)/sqrt(R^(2)+(2*pi*f*L-1/(2*pi*f*C))^(2));
theta(f) = atan(((1/(2*pi*f*C))-2*pi*f*L)/R);
x1 = 0:1000:4000000;
% Calculate the inital distribution (almost)
fplot(Rv(f), [0 4000000])
xlabel('x');
grid on
grid minor
pause(0.01)
2. using function handle
syms f
% Physical properties of the bar
V0 = 1;
R = 1000;
L = 470*10^(-6);
C = 120*10^(-12);
Rv(f) = (V0*R)/sqrt(R^(2)+(2*pi*f*L-1/(2*pi*f*C))^(2));
theta(f) = atan(((1/(2*pi*f*C))-2*pi*f*L)/R);
x1 = 0:1000:4000000;
Rvf = matlabFunction(Rv);
% Calculate the inital distribution (almost)
plot(x1,Rvf(x1))
xlabel('x');
grid on
grid minor
pause(0.01)

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Centre d'aide et File Exchange

Produits

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by