Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
repair sript

Subject: repair sript

From: wahyoe Unggul

Date: 16 Jun, 2010 20:11:19

Message: 1 of 12

you can help me
I make sript from matlab to plane Frame structures 3D analyse,
for 25 element/member ( example of 1), analysis process can be done swiftly,
but for joint with number of 1000 element/member ( example 2)
processed its(the analysis eating finite time of 6 hour(clock,
does you can assist I to improve or repair sript,
to process analysis can be done swiftly (fast analysis).
will name of your email, I will send sript example
thank's before

regard
wahyoe
wahyoe_slipnot@yahoo.co.id

Subject: repair sript

From: us

Date: 16 Jun, 2010 20:31:42

Message: 2 of 12

"wahyoe Unggul" <wahyoe_slipnot@yahoo.co.id> wrote in message <hvbb57$7lk$1@fred.mathworks.com>...
> you can help me
> I make sript from matlab to plane Frame structures 3D analyse,
> for 25 element/member ( example of 1), analysis process can be done swiftly,
> but for joint with number of 1000 element/member ( example 2)
> processed its(the analysis eating finite time of 6 hour(clock,
> does you can assist I to improve or repair sript,
> to process analysis can be done swiftly (fast analysis).
> will name of your email, I will send sript example
> thank's before
>
> regard
> wahyoe
> wahyoe_slipnot@yahoo.co.id

CSSM is a NG - thus, CSSMers do not communicate by email...

us

Subject: repair sript

From: Walter Roberson

Date: 16 Jun, 2010 21:21:33

Message: 3 of 12

wahyoe Unggul wrote:
> you can help me
> I make sript from matlab to plane Frame structures 3D analyse, for 25
> element/member ( example of 1), analysis process can be done swiftly,
> but for joint with number of 1000 element/member ( example 2)
> processed its(the analysis eating finite time of 6 hour(clock,
> does you can assist I to improve or repair sript,
> to process analysis can be done swiftly (fast analysis).

Given that description is seems most probable to me that you are not
pre-allocating your results array and that your routine is spending a lot of
time expanding the results array as you write new values.

Have you used the matlab profiler to determine where your routine is spending
most of its time?

Subject: repair sript

From: wahyoe Unggul

Date: 18 Jun, 2010 23:48:04

Message: 4 of 12

Can you help me, can function under these modified to use smaller memory
function [A]=assembly;

load scratch_file.txt;
tA=scratch_file;clear scratch_file;
m=max(tA(:,2));
A=zeros(m,m);
%B=zeros(size(tA));
B=A;C=A;
for i=1:length(tA);
    C=A;
   B(tA(i,2),tA(i,3))=tA(i,1);
  A(tA(i,2),tA(i,3))=B(tA(i,2),tA(i,3))+C(tA(i,2),tA(i,3));
end;
delete scratch_file.txt;

Subject: repair sript

From: Walter Roberson

Date: 19 Jun, 2010 00:42:52

Message: 5 of 12

wahyoe Unggul wrote:
> Can you help me, can function under these modified to use smaller memory
> function [A]=assembly;
>
> load scratch_file.txt;
> tA=scratch_file;clear scratch_file;
> m=max(tA(:,2));
> A=zeros(m,m);
> %B=zeros(size(tA));
> B=A;C=A;
> for i=1:length(tA);
> C=A;
> B(tA(i,2),tA(i,3))=tA(i,1);
> A(tA(i,2),tA(i,3))=B(tA(i,2),tA(i,3))+C(tA(i,2),tA(i,3));
> end;
> delete scratch_file.txt;

You did not respond to my questions and code that was in reply to your
posting of the same question under the title "accelerating function".

Subject: repair sript

From: wahyoe Unggul

Date: 19 Jun, 2010 01:00:21

Message: 6 of 12

I do not use Matlab profiler, I calculate the time to execute a matrix with the manual, I think there is an error function "assembly", when entering data (matrix) small size can be executed quickly but instead, jiak data (matrix) large size is very slow (time old) to be executed, can you help to correct the above functions so that data (matrix) which can be executed with large quick times
thanks before

Subject: repair sript

From: Walter Roberson

Date: 19 Jun, 2010 02:43:49

Message: 7 of 12

wahyoe Unggul wrote:
> I do not use Matlab profiler, I calculate the time to execute a matrix
> with the manual, I think there is an error function "assembly", when
> entering data (matrix) small size can be executed quickly but instead,
> jiak data (matrix) large size is very slow (time old) to be executed,
> can you help to correct the above functions so that data (matrix) which
> can be executed with large quick times

It appears I have to repeat myself as you are having trouble finding my
previous posting:

=== begin what I already posted ===

Is it correct that you do not care what the values of B and C are after
the loop? If so then your loop becomes

for i = 1:length(tA)
   A(tA(i,2),tA(i,3)) = tA(i,1) + A(tA(i,2),tA(i,3));
end

Which can be optimized to a plain vector calculation as

T = sub2ind(size(A),tA(i,2),tA(i,3));
A(T) = A(T) + tA(:,1);


If, though, the tA(i,2),tA(i,3) pairs might be duplicated, then

T = sub2ind(size(A),tA(i,2),tA(i,3));
T1 = accumarray(T,tA(:,1));
T2 = unique(T);
A(T2) = A(T2) + T1(T2);


=== end what I already posted ===

Your existing code does a lot of needless copying.

Your existing code does not pre-allocate memory properly for the case
where max(tA(:,3)) is greater than max(tA(:,2))

*Are* duplicate pairs of tA(i,2), tA(i,3) possible, or is every pair unique?

Subject: repair sript

From: wahyoe Unggul

Date: 19 Jun, 2010 11:02:05

Message: 8 of 12

Walter Roberson <roberson@hushmail.com> wrote in message <G9WSn.1$Yo5.0@newsfe01.iad>...
> wahyoe Unggul wrote:
> > I do not use Matlab profiler, I calculate the time to execute a matrix
> > with the manual, I think there is an error function "assembly", when
> > entering data (matrix) small size can be executed quickly but instead,
> > jiak data (matrix) large size is very slow (time old) to be executed,
> > can you help to correct the above functions so that data (matrix) which
> > can be executed with large quick times
>
> It appears I have to repeat myself as you are having trouble finding my
> previous posting:
>
> === begin what I already posted ===
>
> Is it correct that you do not care what the values of B and C are after
> the loop? If so then your loop becomes
>
> for i = 1:length(tA)
> A(tA(i,2),tA(i,3)) = tA(i,1) + A(tA(i,2),tA(i,3));
> end
>
> Which can be optimized to a plain vector calculation as
>
> T = sub2ind(size(A),tA(i,2),tA(i,3));
> A(T) = A(T) + tA(:,1);
>
>
> If, though, the tA(i,2),tA(i,3) pairs might be duplicated, then
>
> T = sub2ind(size(A),tA(i,2),tA(i,3));
> T1 = accumarray(T,tA(:,1));
> T2 = unique(T);
> A(T2) = A(T2) + T1(T2);
>
>
> === end what I already posted ===
>
> Your existing code does a lot of needless copying.
>
> Your existing code does not pre-allocate memory properly for the case
> where max(tA(:,3)) is greater than max(tA(:,2))
>
> *Are* duplicate pairs of tA(i,2), tA(i,3) possible, or is every pair unique?
+++++++++++++++++++++++++++++++++++++++++++++++++
very-very fantastic
thank ypu very^2 much
of B and C do not affect the function or loop
after replacing my script
for i=1:length(tA);
> C=A;
> B(tA(i,2),tA(i,3))=tA(i,1);
> A(tA(i,2),tA(i,3))=B(tA(i,2),tA(i,3))+C(tA(i,2),tA(i,3));
> end;
into this script
for i = 1:length(tA)
> A(tA(i,2),tA(i,3)) = tA(i,1) + A(tA(i,2),tA(i,3));
> end
very^2 fantastic
I once had to wait hours to complete the data (matrix) are large, now less than a minute I got some results
whether additional below inserted after the "end" or between "for" and "end"?
T = sub2ind(size(A),tA(i,2),tA(i,3));
> A(T) = A(T) + tA(:,1);
>
> or
> T = sub2ind(size(A),tA(i,2),tA(i,3));
> T1 = accumarray(T,tA(:,1));
> T2 = unique(T);
> A(T2) = A(T2) + T1(T2);
thanks before

Subject: repair sript

From: Walter Roberson

Date: 19 Jun, 2010 13:44:38

Message: 9 of 12

wahyoe Unggul wrote:

> whether additional below inserted after the "end" or between "for" and
> "end"?
> T = sub2ind(size(A),tA(i,2),tA(i,3));
>> A(T) = A(T) + tA(:,1);
>>
>> or
>> T = sub2ind(size(A),tA(i,2),tA(i,3));
>> T1 = accumarray(T,tA(:,1));
>> T2 = unique(T);
>> A(T2) = A(T2) + T1(T2);

Either of those *replace* the loop. The first of them can be used if
there are no cases in which [tA(i,2),tA(i,2)] == [tA(k,2),tA(k,2)] for
some i and k. The second of them should work (I think) in the case where
there are repeated pairs.

Subject: repair sript

From: wahyoe Unggul

Date: 19 Jun, 2010 17:49:07

Message: 10 of 12

Walter Roberson <roberson@hushmail.com> wrote in message <aR3Tn.8779$1Q5.2332@newsfe08.iad>...
> wahyoe Unggul wrote:
>
> > whether additional below inserted after the "end" or between "for" and
> > "end"?
> > T = sub2ind(size(A),tA(i,2),tA(i,3));
> >> A(T) = A(T) + tA(:,1);
> >>
> >> or
> >> T = sub2ind(size(A),tA(i,2),tA(i,3));
> >> T1 = accumarray(T,tA(:,1));
> >> T2 = unique(T);
> >> A(T2) = A(T2) + T1(T2);
>
> Either of those *replace* the loop. The first of them can be used if
> there are no cases in which [tA(i,2),tA(i,2)] == [tA(k,2),tA(k,2)] for
> some i and k. The second of them should work (I think) in the case where
> there are repeated pairs.
==================================================
case back to the beginning of the function if the C and B influence on the loop, how to modify the loop in order to complete the matrix that is big enough?

Subject: repair sript

From: Walter Roberson

Date: 19 Jun, 2010 18:19:54

Message: 11 of 12

wahyoe Unggul wrote:
> Walter Roberson <roberson@hushmail.com> wrote in message
> <aR3Tn.8779$1Q5.2332@newsfe08.iad>...
>> wahyoe Unggul wrote:
>>
>> > whether additional below inserted after the "end" or between "for"
>> and > "end"?
>> > T = sub2ind(size(A),tA(i,2),tA(i,3));
>> >> A(T) = A(T) + tA(:,1);
>> >>
>> >> or
>> >> T = sub2ind(size(A),tA(i,2),tA(i,3));
>> >> T1 = accumarray(T,tA(:,1));
>> >> T2 = unique(T);
>> >> A(T2) = A(T2) + T1(T2);
>>
>> Either of those *replace* the loop. The first of them can be used if
>> there are no cases in which [tA(i,2),tA(i,2)] == [tA(k,2),tA(k,2)] for
>> some i and k. The second of them should work (I think) in the case
>> where there are repeated pairs.
> ==================================================
> case back to the beginning of the function if the C and B influence on
> the loop, how to modify the loop in order to complete the matrix that is
> big enough?

I do not understand your question, sorry.

Subject: repair sript

From: wahyoe Unggul

Date: 25 Jun, 2010 19:19:22

Message: 12 of 12

 have a problem with the function (function iteration) below, the data (matrix) is small, the results obtained almost the same iterations but if the data matrix used in large differences in the final iteration on the results of a very large
==========================================
function [DF,AR,AM]=analysis_result(element,dof,index,...
                   IF,IR,S,SmS,JL,AML,RT,Support,type)
clear Sff Srf;

ndof=length([IF IR]); % find number degree of freedom

% Perform Sff matrix
Sff=S(IF,IF);

% Perform Sff matrix
Srf=S(IR,IF);

% create joint load matrix (AJ)
i=1:size(JL,1);
AJ=zeros(1,ndof);
        AJ(dof(JL(i),2))=JL(i,2);
      AJ(dof(JL(i),3))=JL(i,3);
      AJ(dof(JL(i),4))=JL(i,4);
      AJ(dof(JL(i),5))=JL(i,5);
      AJ(dof(JL(i),6))=JL(i,6);
      AJ(dof(JL(i),7))=JL(i,7);
end;
% create joint load ekuivalen matrix AE
[mi,ni]=size(index);
% transpose to .. x m matrix (m=number of element)
AMLT=AML';

AE=zeros(ndof,1);

for i=1:size(element,1);
    Ji=index(i,:);
             AMLi=[ AMLT(1,i) ; AMLT(2,i) ; AMLT(3,i);
             AMLT(4,i) ; AMLT(5,i) ; AMLT(6,i);
             AMLT(7,i) ; AMLT(8,i) ; AMLT(9,i);
             AMLT(10,i); AMLT(11,i); AMLT(12,i)];
    end;
   AE(Ji)=AE(Ji)-RT(:,:,i)'*AMLi;
end;

AE=AE';

% Calculate support reaction (AR) and joint displacement (DF)
AC=AJ+AE;
AFC=AC(IF)';
ARC=AC(IR)';
DF=Sff\AFC;
AR=-ARC+Srf*DF;

% Calculate member forces
Dj=zeros(1,ndof);
AM=zeros(ni,mi);
Dj(IF)=DF;

for i=1:size(element,1);
   DM=RT(:,:,i)*Dj(index(i,:))';
   AM(:,i)=AML(i,:)'+SmS(:,:,i)*DM;
end;

AM=AM.';
%

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us