How to plot an equation that uses multiple files of data

1 回表示 (過去 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 Center および File ExchangeEntering Commands についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by