This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
IT'S BEEN SOLVED!!!
I've been working on a script to read the coordinates of airfoils taken from this website to slightly modify them so that I can do an analysis, since some of the airfoils are not actually well defined.
But when I try to read the .dat file, the dlmread function gives me the error that the index exceeds the matrix dimensions, although I have initialiazed the matrices. The .dat files have two sets of data for the top and bottom of the airfoils, each having 102 points, with the name of the airfoil on top of the file.
Here's the whole script I wrote and I can't find any mistakes. Also MatLab check doesn't seem to highlight any wrong thing.
clc
clear all
close all
NACA_numbers=[20010; 20012; 20402; 20403; 20404; 20406; 20410; 20412; 20414; 20503; 20518; 20606; 20610; 20612; 20614; 20706; 20710; 20712; 20714; 21006; 21010];
dorso=zeros(102,2);
ventre=zeros(102,2);
ventre_2=zeros(102,2);
pathread='/Users/macbookpro/Desktop/temporary/xfoil/profili/';
pathwrite = '/Users/macbookpro/Desktop/temporary/xfoil/profili aggiornati/';
for i=1:21
filenameread=['sc' num2str(NACA_numbers(i,:), '%5.5d') '.dat'];
fileread=[pathread filenameread];
EDIT II: the mistake is in the delimiter: instead of '\t' I substitute with ' ', and instead of using commas in the [ #, #, #,#] I just typed: [# # # #]. Kudos to user terennum to making me use the example found in the help.
dorso=dlmread(fileread,'\t',[3,0,105,1]);
ventre=dlmread(fileread,'\t',[107,0,210,1]);
delta=dorso(size(dorso,1),2)-ventre(size(dorso, 1), 2);
for k=1:size(dorso, 1)
ventre_2(k,1)=ventre(k,1);
ventre_2(k,2)=ventre(k,2) delta*ventre(k,2);
end
MatrOutput=[dorso(:,1) dorso(:,2)];
MatrOutput2=[ventre_2(:,1) ventre_2(:,2)];
dlmwrite([pathwrite 'sc' num2str(NACA_numbers(i,:), '%5.5d') '.dat'], MatrOutput, 'delimiter','\t','precision','.10f');
dlmwrite([pathwrite 'sc' num2str(NACA_numbers(i,:), '%5.5d') '.dat'], MatrOutput2, '-append', 'delimiter','\t','precision','.10f');
end
EDIT: here's the message error given to me:
??? Index exceeds matrix dimensions.
Error in ==> dlmread at 157
result= result(:,1:ncols);
Error in ==> chiusura_profilo at 20
dorso=dlmread(fileread,'\t',[3,0,105,1]);
with chiusura_profilo being the script name.
Post Details
- Posted
- 8 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/matlab/comm...