need help with loop

조회 수: 2 (최근 30일)
Yash Raj Haldaniya
Yash Raj Haldaniya 2022년 4월 24일
답변: Bharat Chandra Mukkavalli 2022년 7월 11일
hello guys, i'm very new to matlab and currently facing some problems in loop coding.
so firstly i want to make a loop of a matrix i don't how much its size will be.
so i've an equation for a node like phi(i, j)= {some constant}*{(phi(i-1, j-1)-2*phi(i, j-1)+phi(i+1, j-1)} Where i is an number that shows my node location in X-Y plane and j shows my node location in Z plane. its kind of taylor series problem i think.
i want this loop to run till i get phi(i, j)= phi(i, j-1) and store all the values in a matrix.(for storing i and j can also work as raw and column)
hopefully you guys can give me some tips.
Thank You
  댓글 수: 2
Sam Chak
Sam Chak 2022년 4월 24일
@Yash Raj Haldaniya, Can give an example using a simple matrix like the following?
M = [2 1; 4 3]
M =
3 1
4 2
Yash Raj Haldaniya
Yash Raj Haldaniya 2022년 4월 24일
i'm attaching what i've done so far so you can get an idea. please dont mind the messy code im very new in this.

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

답변 (1개)

Bharat Chandra Mukkavalli
Bharat Chandra Mukkavalli 2022년 7월 11일
Hi,
I went through the code but unfortunately I couldn't understand what you are trying to do.
Please explain in detail what it is you are trying to achieve.
I have changed the loop to a nested loop and modified the if condition (from "==" to "isequal()"), since the original code was throwing errors.
Please find the attached updated code file.
Hope it is helpful!

카테고리

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