How to plot an equation that uses multiple files of data

1 view (last 30 days)
I am trying to plot the equation Zc over frequency.
There are 5 text files that are given in this code, for right now I am just using 3, freq1, Rzero1, and Lzero.
The problem is when I go to plot(freq1,Zc). I get a Error using plot Vectors must be the same length.
Attached is the 3 text files and below is the code and what the graph is supposed to look like.
clear all;
clc;
load freq1.txt;
load Rzero1.txt;
load Lzero1.txt;
load Rpos1.txt;
load Lpos1.txt;
Czero = 7.524/1e3;
Cpos = 1.2027/1e3;
Gzero = 2/1e8;
Gpos = 2/1e8;
w(1)=0;
Zc(1)=0;
i=1;
k=1;
n=10;
for i=1:(size(Rzero1,1)-1)/n
w(i) = 2*pi*freq1(k);
Zc(i) = sqrt(((Rzero1(k+n/2)+1j*w*Lzero1(k+n/2))/(Gzero+1j*w*Czero)));
k=k+n;
end
plot(freq1,Zc);

Accepted Answer

VBBV
VBBV on 24 Oct 2020
I see the graph with log scale on x axis
See the code
clear all;
clc;
load freq1.txt;
load Rzero1.txt;
load Lzero1.txt;
%load Rpos1.txt;
%load Lpos1.txt;
Czero = 7.524/1e3;
Cpos = 1.2027/1e3;
Gzero = 2/1e8;
Gpos = 2/1e8;
w(1)=0;
Zc(1)=0;
i=1;
k=1;
n=10;
for i=1:size(Rzero1,1)
w(i) = 2*pi*freq1(i);
Zc(i) = sqrt(((Rzero1(i)+1j*w*Lzero1(i))/(Gzero+1j*w*Czero)));
% k=k+n;
end
semilogx(freq1,Zc);
figure(2)
plot(freq1,Zc)

More Answers (0)

Categories

Find more on Entering Commands in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!