Open all .txt files in a folder and import data to graph

1 visualización (últimos 30 días)
Sarah Brianne
Sarah Brianne el 28 de Jun. de 2018
Hello,
I could technically do this in excel but I have a lot of graphs with 8-11 plots each. I am trying to develop a matlab code that will plot all .txt files into one graph with two subplots. I would like to plot the abs of the data in column 3 vs column 2 and column 1 vs column 4. I am having issues doing this. Feel I am close but very far away. Here is the code I have started trying to develop. Any help would be much appreciated. Thanks!
clc; close all;
Files=dir('C:\Users\Sarah\Desktop\Sarah_2018\DI_Trial_1'); for k=1:length(Files) FileNames=Files(k).name delimiterIn = ' '; headerlinesIn = 8; impDAT = importdata(Files(k), delimiterIn, headerlinesIn); DAT1(k)= abs(impDAT.data(:,3)); DAT2(k)= impDAT.data(:,2); DAT3(k)= log(impDAT.data(:,1)); DAT4(k)= log(impDAT.data(:,4)); end
figure(1); subplot(2, 2, 1); plot(DAT3, DAT2, '.', 'Color', 'red'); titstr=sprintf('This is a plot'); title(titstr,'FontSize',13); xlabel('Z"/ohm'); ylabel("Z'/ohm"); grid on;
subplot(2, 2, 2); plot(DAT1, DAT4, '.', 'Color', 'blue'); titstr=sprintf('This is a second plot'); title(titstr,'FontSize',13); xlabel('Freq/Hz'); ylabel('Z/ohm'); grid on;

Respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by