Hi. It's been a while since I've used matlab. I have some graphs in .trc files and I've been given a function that is supposed to be able to plot these files, but I'm having a hard time figuring out how it's done. Here's the function:

댓글 수: 1

Code is:
function ExamplePlotImpedances(code,no)
% function ExamplePlotImpedances(src)
%
% Example program
% Load and plot a group of impedance measurements from HP8753,
% saved as S11-parameters
% From functions written in LabVIEW at HBV-IMST
Zref = 50; % Ohm Reference impedance
%-- Build fileames --
Nf = length(no);
for k=1:Nf
src{k}= sprintf('%s%04d.trc', code, no(k));
end
for k=1:Nf
%--- Load raw data ---
trc(k)= readtrace(src{k});
%--- Create frequency vector, calculate Z, and plot impedance ---
f{k}= [0:trc.Np-1]*trc.dx+trc.x0; % Hz Frequency vector
end
S11{k} = double(trc.y(:,1)+ 1i*trc.y(:,2));
Z = Zref* (1+S11{k})./(1-S11{k}); % Ohm Complex impdance
end
keyboard
subplot(2,2,1)
semilogy(f,abs(Z));
xlabel('Frequency [Hz]')
ylabel('Impedance magnitude [Ohm]')
grid on
subplot(2,2,3)
phi = angle(Z);
plot(f,rad2deg(phi));
xlabel('Frequency [Hz]')
ylabel('Phase [deg]')
ylim([-90 90])
set(gca, 'ytick', [-90:30:90])
grid on
subplot(2,2,2)
plot(f, real(Z), 'b-', f, imag(Z), 'r-');
xlabel('Frequency [Hz]')
ylabel('Impedance [Ohm]')
grid on
subplot(2,2,4)
plot(f, real(S11), 'b-', f, imag(S11), 'r-');
xlabel('Frequency [Hz]')r
ylabel('S11')
ylim([-1 1])
grid on
keyboard
return

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2017년 5월 12일

0 개 추천

댓글 수: 8

Weifu
Weifu 2017년 11월 21일
Hi, I'm using Matlab 2016b now and it seems this function does not correct due to textscan function error. Does textscan function changed for 2014 and 2016 Matlab? Thanks.
Walter Roberson
Walter Roberson 2017년 11월 21일
What error message are you seeing?
Margareta Drozdikova
Margareta Drozdikova 2018년 5월 2일
편집: Walter Roberson 2018년 5월 2일
Hi , I have some problem. I use readtrc function, I wrote readtrc('subor.trc') and error is
Subscript indices must either be
real positive integers or logicals.
Error in readtrc (line 20)
traces{k+1,1}=cell2mat(Columns(TracesIdx(size(TracesIdx))+4:size(Rows{1,1})));
Error in skuska1 (line 1)
readtrc('subor.trc')
how can I solve it?
thanks
Walter Roberson
Walter Roberson 2018년 5월 2일
Can you zip up the .trc file and attach the zip here?
Dear all,
have you been able to solve this problem? I have the same error:
Subscript indices must either be real positive integers or logicals.
Error in readtrc (line 20)
traces{k+1,1}=cell2mat(Columns(TracesIdx(size(TracesIdx))+4:size(Rows{1,1})));
Error in LeCroy_testy (line 5)
traces=readtrc('dane.trc');
I would be gratefull for your help!
Walter Roberson
Walter Roberson 2020년 7월 21일
Can you attach or link to the .trc file for testing?
Alessandro Verniani
Alessandro Verniani 2021년 10월 15일
The attached .trc file has both strings and integers, causing the readtrc function to error. If there are any solutions, please advise!
Walter Roberson
Walter Roberson 2021년 10월 15일
That appears to be a binary .trc file, but the File Exchange contribution https://www.mathworks.com/matlabcentral/fileexchange/48919-readtrc-read-r-s-trc-files-into-a-matlab-cell-array is expecting only text files.
Your .trc file is LECROY_2_3 format. You should get ReadLeCroyBinaryWav​eform by Jean-Daniel Deschênes from the File Exchange.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Data Import and Export에 대해 자세히 알아보기

질문:

2017년 5월 12일

댓글:

2021년 10월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by