What is wrong with my code when it has no errors but does nothing when i try to run it?
Afficher commentaires plus anciens
I am not sure how to troubleshoot the cause of this issue. I am trying to calculate something from the data in specific columns of several different CSV files at once so I can efficiently average the data. This is the first time I have used matlab for such purposes so I apologize if I am missing something relatively obvious. I am also doing this on a macbook pro if that is a possible problem.
Here is my code:
strDir = '/Users/Pathway/Documents/csvfiles';
fnames = dir(strcat(strDir, '*.csv'));
numfids = length(fnames);
m = zeros(1,numfids);
u = zeros(1,numfids);
for i = 1:numfids
f = fopen(strcat(strDir, fnames(i).name));
X = textscan(fid, '%s%f%f%f%f%f%f%f%f', 'Delimiter', ',', 'HeaderLines', 47);
col1 = X(:,3);
col2 = X(:,4);
m(i) = (X(70,4) - X(20,4))./(X(70,3) - X(20,3));
D = 20; % M/L
V_d = 100; % Constant Drain Voltage
C_i = 1.5E-8; % Capacitance of Dielectric F/ cm^2
u(i) = (m(i))./(D .* C_i .* V_d); % mobility
fclose(f);
end
disp(m)
disp(u)
Even though I write in for the values to be displayed nothing comes up even though there are no errors. Its as if no files are found but I can assure you that the file being directed to(csvfiles) exclusively has 7 cvs files within it. Please take a look at the attached screen shot to see what the workspace looks like after running the code.
Does anyone have any advice? Any form of assistance will be appreciated. Thank you.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Variables dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!