Combining multiple plots in 1 graph

3 次查看(过去 30 天)
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 !

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by