Index exceeds the number of array elements (0).

Illustration
ammar.alhete22 - 2022-04-02T15:55:01+00:00
Question: Index exceeds the number of array elements (0).

% In this program, we want to find the centre and aim point of each element % on the coil surface clc; clear all; tic data=xlsread('focus.csv'); index =find(isnan(data(:,1))==1); l=length(data); nodes =data(1:index(1)-1,2:4); faces =data(index(2)+1:l,1:4) +1; % Finding the indices of triangular (it) and quadrilateral (iq) elements it=find(isnan(faces(:,4))==1); t=length(it); iq=find(isnan(faces(:,4))==0); q=length(iq); %% Opening lines for Sol-Trace input file L1= ['STAGE XYZ 0 0 0 AIM 0 0 1 ZROT 0 VIRTUAL 1 MULTIHIT 0 ELEMENTS ',num2str(t+q),' TRACETHROUGH 0']; L2='focus'; file=fopen('focus.stinput', 'w'); fprintf(file, '%s\n%s\n', L1,L2); %% Sub-program for triangles if isempty(it)==0 [area,mid,aim,quad]=triangles(nodes,faces,it); % Print the triangle elements for i=1 : t fprintf(file, '%d\t%f\t%f\t%f\t%f\t%f\t%f\t%d\t%s\t', 1, mid(i,1),mid(i,2),mid(i,3),aim(i,1),aim(i,2),aim(i,3),0,'i'); fprintf(file, '%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%s\t', quad(i,1),quad(i,2),quad(i,3),quad(i,4),quad(i,5),quad(i,6),quad(i,7),quad(i,8),'f'); fprintf(file, '%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t\t\t%d\t\n', 0,0,0,0,0,0,0,0,2); end end %% Sub-program for quadrilaterals if isempty(iq)==0 [area(t+1:t+q,:),mid(t+1:t+q,:),aim(t+1:t+q,:),quad(t+1:t+q,:)] = quadrilaterals(nodes,faces,iq); % Print the quadrilateral elements for i=t+1 : t+q fprintf(file, '%d\t%f\t%f\t%f\t%f\t%f\t%f\t%d\t%s\t', 1, mid(i,1),mid(i,2),mid(i,3),aim(i,1),aim(i,2),aim(i,3),0,'q'); fprintf(file, '%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%s\t', quad(i,1),quad(i,2),quad(i,3),quad(i,4),quad(i,5),quad(i,6),quad(i,7),quad(i,8),'f'); fprintf(file, '%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t\t\t%d\t\n', 0,0,0,0,0,0,0,0,2); end end % fclose(file); toc

Expert Answer

No answer yet

Get a Free Consultation or a Sample Assignment Review!