New Matlab user here and I am stuck trying to figure out how to set up Euler's Method for the following problem:
𝑦′ =sin(𝑡)∗(1−𝑦) with 𝑦(0)=𝑦0 and 𝑡≥0
The teacher for the class I am taking provided us with the following code to use for Euler's Method. The code has been modified with my most recent attempt to solve the problem above. His template worked fine for the problem listed at the top and several others, but when I changed out the variables for the problem above and I get the error message listed at the bottom. I have tried various ways of inputing the code that I found on YouTube or Google searches and none have been able to help. What am I doing wrong?
h = 1/16;
a = 0;
b = 20;
n = 321;
x = zeros(n,1);
y = zeros(n,1);
x = linspace(a,b,n)';
y(1) = 6;
for i = 1:n-1
y(i+1) = y(i) + h *((sin(x) * ( 1 - y(i)) ;
Error: File: Euler_Method.m Line: 21 Column:
Invalid expression. When calling a function
or indexing a variable, use parentheses.
Otherwise, check for mismatched delimiters.