필터 지우기
필터 지우기

How can you run two for loops simultaneously?

조회 수: 2 (최근 30일)
Jacob
Jacob 2014년 3월 23일
답변: Image Analyst 2014년 3월 23일
I am trying to create the gauss seidel iterative method and im trying thus to create two for loops that run at the same time. For example:
function [y]=gaussseidel2(a,b)
[n,m]=size(a); [k,l]=size(b);
x=zeros(m,1)
eps=1e-3;
for j=1:n
for i=1:m
for k=1:m
x(i)=(b(j,1)-a(j,1)*x(1)-a(j,2)*x(2)-a(j,3)*x(3)-a(j,4)*x(4))/a(j,j)
end
end
end
end
My problem is that i want to create a very general method were i can control my number of x's and columns and rows and then compute my x's. I still need the while but i would like some advices on how my problem and other advices.
Thanks :)
  댓글 수: 1
Jan
Jan 2014년 3월 23일
The question is not clear. What are the two FOR loops, which should run "in parallel"? Currently x(i) is overwritten repeatedly.

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

답변 (1개)

Image Analyst
Image Analyst 2014년 3월 23일
Perhaps the Parallel Computing Toolbox (which I do not have): http://www.mathworks.com/products/parallel-computing/?s_tid=hp_fp_list

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by