Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Subscripted assignment dimension mismatch

2 visualizaciones (últimos 30 días)
Hamid
Hamid el 16 de Ag. de 2014
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
??? Subscripted assignment dimension mismatch.
Error in ==> bintranslate at 143
Ep(i/numbitEp,:)=available(ceil(bin2dec(num2str(chromosome4(i-(numbitEp-3):i)))),:);
This is my m file. can anyone help me out please????
function [Coord,Edof,Ep]=bintranslate(available,chromosome,Dof,fixedcoord,na,nb,neft,nevt,nl,nn,numbitCoordX,numbitCoordY,numbitCoordZ,numbitEdof,numbitEp,xspan,yspan,zspan)
format short
% Extracting nodal coordinates
if numbitCoordX==0
Coord=1e-1*fixedcoord;
else
chromosome1=chromosome(1:numbitCoordX*(nn-nb-nl));
chromosome2=chromosome(1+numbitCoordX*(nn-nb-nl):numbitCoordX*(nn-nb-nl)+numbitCoordY*(nn-nb-nl));
chromosome3=chromosome(1+numbitCoordX*(nn-nb-nl)+numbitCoordY*(nn-nb-nl):numbitCoordX*(nn-nb-nl)+numbitCoordY*(nn-nb-nl)+numbitCoordZ*(nn-nb-nl));
variablecoord=zeros(nn-(nb+nl),3);
for i=numbitCoordX:numbitCoordX:numbitCoordX*(nn-nb-nl)
if round(bin2dec(num2str(chromosome1(i-(numbitCoordX-1):i))))>xspan
variablecoord(i/numbitCoordX,1)=xspan-1;
else
variablecoord(i/numbitCoordX,1)=round(bin2dec(num2str(chromosome1(i-(numbitCoordX-1):i))));
end
end
for i=numbitCoordY:numbitCoordY:numbitCoordY*(nn-nb-nl)
if round(bin2dec(num2str(chromosome2(i-(numbitCoordY-1):i))))>yspan
variablecoord(i/numbitCoordY,2)=yspan;
else
variablecoord(i/numbitCoordY,2)=round(bin2dec(num2str(chromosome2(i-(numbitCoordY-1):i))));
end
end
for i=numbitCoordZ:numbitCoordZ:numbitCoordZ*(nn-nb-nl)
if round(bin2dec(num2str(chromosome3(i-(numbitCoordZ-1):i))))>zspan
variablecoord(i/numbitCoordZ,3)=zspan-1;
else
variablecoord(i/numbitCoordZ,3)=round(bin2dec(num2str(chromosome3(i-(numbitCoordZ-1):i))));
end
end
Coord=1e-1*[fixedcoord;variablecoord];
end
chromosome4=chromosome(1+(numbitCoordX+numbitCoordY+numbitCoordZ)*(nn-nb-nl):numbitEp*(neft+nevt)+(numbitCoordX+numbitCoordY+numbitCoordZ)*(nn-nb-nl));
chromosome5=chromosome(1+length(chromosome)-3*nevt*numbitEdof:length(chromosome)-nevt*numbitEdof);
chromosome6=chromosome(1+length(chromosome)-nevt*numbitEdof:length(chromosome));
if numbitEdof == 0
Edof=0;
else
add=0.01*[1:50]';
Coord1=Coord(:,1)+add(1:size(Coord,1));
sortcoord=sort(Coord1);
% Creating a basic structure
A=zeros(neft,3);B=zeros(neft,3);
A(neft,:)=Dof(find(Coord1==sortcoord(end-1),1),:);
B(1,:)=Dof(find(Coord1==sortcoord(2),1),:);
for i=3:3:neft-1
A(i-2,:)=Dof(find(Coord1==sortcoord(i/3),1),:);
A(i-1,:)=Dof(find(Coord1==sortcoord(i/3),1),:);
A(i,:)=Dof(find(Coord1==sortcoord(i/3),1),:);
B(i,:)=Dof(find(Coord1==sortcoord((i+6)/3),1),:);
B(i+1,:)=Dof(find(Coord1==sortcoord((i+6)/3),1),:);
B(i+2,:)=Dof(find(Coord1==sortcoord((i+6)/3),1),:);
end
% Extracting the elements with variable topology
if nevt==0
Edof=[(1:neft)' A B];
else
C=zeros(nevt,3);D=zeros(nevt,3);
for i=numbitEdof:numbitEdof:numbitEdof*nevt
if ceil(bin2dec(num2str(chromosome5(i-(numbitEdof-1):i))))>nn
C(i/numbitEdof,:)=Dof(nn,:);
elseif ceil(bin2dec(num2str(chromosome5(i-(numbitEdof-1):i))))==0
C(i/numbitEdof,:)=Dof(1,:);
else
C(i/numbitEdof,:)=Dof(ceil(bin2dec(num2str(chromosome5(i-(numbitEdof-1):i)))),:);
end
if ceil(bin2dec(num2str(chromosome6(i-(numbitEdof-1):i))))>nn
D(i/numbitEdof,:)=Dof(nn,:);
elseif ceil(bin2dec(num2str(chromosome6(i-(numbitEdof-1):i))))==0
D(i/numbitEdof,:)=Dof(1,:);
else
D(i/numbitEdof,:)=Dof(ceil(bin2dec(num2str(chromosome6(i-(numbitEdof-1):i)))),:);
end
end
Edof=[(1:neft)' A B;(1+neft:neft+nevt)' C D];
end
end
% Extracting the element properties
Ep=zeros(neft+nevt,6);
for i=numbitEp:numbitEp:(neft+nevt)*numbitEp
if ceil(bin2dec(num2str(chromosome4(i-(numbitEp-1):i))))>na
Ep(i/numbitEp,:)=available(na,:);
elseif ceil(bin2dec(num2str(chromosome4(i-(numbitEp-1):i))))==0
Ep(i/numbitEp,:)=available(1,:);
else
Ep(i/numbitEp,:)=available(ceil(bin2dec(num2str(chromosome4(i-(numbitEp-1):i)))),:);
end
end
%--------------------------end--------------------------------

Respuestas (1)

Image Analyst
Image Analyst el 16 de Ag. de 2014
Break
Ep(i/numbitEp,:)=available(ceil(bin2dec(num2str(chromosome4(i-(numbitEp-3):i)))),:);
up into parts and examine them all with the debugger to figure out what their values are. For example
d1 = i/numbitEp
d2 = i-(numbitEp-3)
d3 = chromosome4(d2:i)
d4 = num2str(d3)
and so on.
  2 comentarios
Hamid
Hamid el 17 de Ag. de 2014
How can I do this??
I'm a new starter at MATLAB, please HELP me

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by