Combining multiple plots in 1 graph

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 Comment

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.

Sign in to comment.

 Accepted Answer

Bhaskar R
Bhaskar R on 26 Dec 2019
Edited: Bhaskar R on 26 Dec 2019
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 !

More Answers (0)

Categories

Find more on MATLAB Mobile in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!