How can I plot the function of Resistor Voltage Vr

In this situation, I am assuming frequency f is a unknown varible ( just like variable x). I want to plot a graph of function Vr ( resistor voltage) in the range frequency of [0, 4e6] where Vr = (Vo*R)/Z
clear all
clc
% Define the value of R,C,L
R = 1000;
C = 120e-12;
L = 470e-6;
f = 4e6;
V0 = 220;
syms f
% Define the function of Resistor Voltage Vr
Vr = (V0*R)/sqrt((R^2)+(2*pi*f*L - 1/2*pi*f*C)^2);
fplot(@(f) Vr,[0 4e6])

 Réponse acceptée

You are almost there. Define ‘f’ as an anonymous function, vectorise it, and plot:
% Define the value of R,C,L
R = 1000;
C = 120e-12;
L = 470e-6;
f = 4e6;
V0 = 220;
% Define the function of Resistor Voltage Vr
Vr = @(f) (V0*R)./sqrt((R^2)+(2*pi*f*L - 1/2*pi*f*C).^2);
fplot(Vr,[0 4e6])
That worked when I ran it. (The Symbolic Math Toolbox ios not required here.)
From my experience, an extra set of parentheses iw likelly necessary, so consider this:
Vr = @(f) (V0*R)./sqrt((R^2)+(2*pi*f*L - 1./(2*pi*f*C)).^2);
instead.

2 commentaires

Phillip Phuc
Phillip Phuc le 28 Avr 2020
Modifié(e) : Phillip Phuc le 28 Avr 2020
Thank you so much Star Strider, it ran perfectly. And may I know what does the dot "." mean ?
As always, my pleasure!
The dot operators (with multiplication, division, and exponentiation) indicate element-wise or array operations. See: Array vs. Matrix Operations for a full discussion. (The exception is the transpose operator (') that ordinarilly does a complex-conjuage transpose although (.') does a simple transpose with the conjugate operation.)

Connectez-vous pour commenter.

Plus de réponses (1)

Richard Duran
Richard Duran le 20 Oct 2020

0 votes

Write a function called voltage that computes the voltages at different junctions.help please

1 commentaire

Here is the solution to your question:
function [a,b] = lin_reg(x,y)
len = length(x);
aug = [x' ones(len,1)];
res = aug\y';
a = res(1);
b = res(2);
end

Connectez-vous pour commenter.

Catégories

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

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by