Solving equations in a for loop with changing variables
Show older comments
Hi all,
Not very experienced with matlab and trying to solve for d, L, and H as a function of x changing. The assignment asks that for the first half of x, H=0.5 and d=1.9 but I haven't been able to figure out how to start the loop in the middle of those vectors. I hardcoded a little bit to try to troubleshoot my first line, but the loop skews my depth somehow. Any advice would be greatly appreciated!
2 Comments
Stephan
on 30 Oct 2020
please insert your code - we can not copy a code from a picture...
Samantha Andeson
on 31 Oct 2020
Answers (1)
Juan Sagarduy
on 30 Oct 2020
0 votes
Hi Samantha The first line in your code in the loop is not correct. It should d(i)=d(i-1)-S.*x(i). But then the loop must start with i=2. Otherwise, MATLAB would throw an error. Good luck / Juan
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!