필터 지우기
필터 지우기

problem with assigning in a loop

조회 수: 1 (최근 30일)
Hamid
Hamid 2014년 12월 14일
댓글: Hamid 2014년 12월 14일
my code runs correctly when lc is 1,I want lc>1 ;
Ed is 45*6 matrix and I think there is a way to assign Ed for lc>1 .
What can I do?
please help.
for i=1:lc
ff=f(:,i);
[a,r]=solveq(K,ff,bc);
Ed=extract(Edof,a);
end
----------------------------------------
function [ed]=extract(edof,a)
[nie,n]=size(edof);
t=edof(:,2:n);
for i = 1:nie
ed(i,1:(n-1))=a(t(i,:))';
end

채택된 답변

Image Analyst
Image Analyst 2014년 12월 14일
편집: Image Analyst 2014년 12월 14일
Store the various values of Ed for different iterations in a cell array
Ed{i} =extract(Edof,a);
or a 3D array
thisEd=extract(Edof,a);
allEd(:,:,i) = thisEd;
If you use a 3D array, be sure to preallocate before the loop starts
Ed=allED(45,6,lc);
  댓글 수: 3
Image Analyst
Image Analyst 2014년 12월 14일
Maybe you need to define Ed as a cell before the loop
Ed = cell(1, lc);
Hamid
Hamid 2014년 12월 14일
excellent, thanks.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by