How to plot an equation that uses multiple files of data

조회 수: 4 (최근 30일)
Matthew Portnoy
Matthew Portnoy 2020년 10월 24일
답변: VBBV 2020년 10월 24일
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);

채택된 답변

VBBV
VBBV 2020년 10월 24일
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)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Specialized Power Systems에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by