Combining multiple plots in 1 graph

조회 수: 4 (최근 30일)
kenneth lee
kenneth lee 2019년 12월 26일
댓글: kenneth lee 2019년 12월 26일
Hi, I would need some help in combining multiple plots in 1 graph please. i will need to combine 20 plots into one graph. However, these 20 plots has 20 seperate text file with different x & y axis, and i am facing difficulty in combining them together. are there any suggestions for me to combine them? i willl also need to combine them after wdenoise as well to see the difference. l had attached the 20 files please help me take a look please. currently i only know how to convert a individual file to a graph and the below are my codes.
filename = 't1-1.txt'
deliminator = ' ';
A = dlmread(filename, deliminator, 14, 0);
resistance = A(:,1);
reactance = A(:,2);
figure(1)
hold on
grid on
grid minor
plot (resistance, reactance, 'blue')
title ('Eddy Current Testing')
xlabel ('Resistance')
ylabel ('Reactance')
A1 = wdenoise(A,5, ...
'Wavelet', 'db5', ...
'DenoisingMethod', 'Bayes', ...
'ThresholdRule', 'Soft', ...
'NoiseEstimate', 'LevelIndependent');
figure(2)
plot(A1(:,1),A1(:,2));
xlabel('Resistance');
ylabel('Reactance');
title('denoised Signal');
  댓글 수: 1
Asif Karim
Asif Karim 2019년 12월 26일
Could you please clarify your requirement ?
  • If you wish to plot all the 20 plots into a single figure window ,the
subplot()
function could help you.
  • If you want to plot the 20 txt files as a single graph
Combining the text files into a single variable and plotting might help.

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

채택된 답변

Bhaskar R
Bhaskar R 2019년 12월 26일
편집: Bhaskar R 2019년 12월 26일
I have used for loops to read and plot signals
% filename = 't1-1.txt';
% assuming your files are in present working directory
files = dir('**/*.txt');
deliminator = ' ';
A = cell(length(files), 1); %
A1 = cell(length(files), 1);
% data storing to variables first
for ii = 1:length(files)
filename = files(ii).name;
A{ii} = dlmread(filename, deliminator, 14, 0); % A data
A1{ii} = wdenoise(A{ii},5, ...
'Wavelet', 'db5', ...
'DenoisingMethod', 'Bayes', ...
'ThresholdRule', 'Soft', ...
'NoiseEstimate', 'LevelIndependent');
end
% plotting Eddy Current Testing all values to figure Eddy Current Testing
figure('Name', 'Eddy Current Testing(A)');
for ii = 1:length(files)
resistance = A{ii}(:,1);
reactance = A{ii}(:,2);
plot (resistance, reactance);
hold on
end
hold off
grid on
grid minor
title ('Eddy Current Testing')
xlabel ('Resistance')
ylabel ('Reactance')
legend(files(:).name);
% plotting Eddy Current Testing all values to figure denoised Signal(A1)
figure('Name', 'denoised Signal(A1)');
for ii = 1:length(files)
plot ( A1{ii}(:,1), A1{ii}(:,2));
hold on
end
hold off
grid on
grid minor
xlabel('Resistance');
ylabel('Reactance');
title('denoised Signal');
legend(files(:).name);
There are better ways also to and andplot signals..
Hope helps you !
  댓글 수: 1
kenneth lee
kenneth lee 2019년 12월 26일
THANKS ALOT! code works for me!

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by