# Finding the functionality for the loop

1 view (last 30 days)
Amy Topaz on 14 Mar 2022
Commented: Amy Topaz on 14 Mar 2022
I am new to Matlab. I am making a formula/syntax book as a part of my club activity. I was finding logics for implementing loops in matlab without actually using loops. Is there any other way?
Is there any other way of writing by not using for loop in matlab
t = linspace(10, 1000, 100);
for 1:n
y(n)=1+t(n)^2;
eq = @(x) (N + x)/(y(n) + k) + N*x*exp(-(t(n)));
end
%Say we need to find the range of values of solution of eq for all values of range
%n. N, k are constants.
%Is it possible to implement the same without for loop
##### 2 CommentsShow 1 older commentHide 1 older comment
Amy Topaz on 14 Mar 2022
yes

Walter Roberson on 14 Mar 2022
syms t N k x
T = linspace(10, 1000, 100).';
y = 1 + t^2;
eqn = (N + x)/(y + k) + N*x*exp(-(t))
eqn = sol_x = solve(eqn, x)
sol_x = sols_x = subs(sol_x, t, T);
sols_x(1:5)
ans = sols_x(end)
ans = vpa(limit(sols_x(end), N, 1))
ans = vpa(limit(sols_x(end), N, inf))
ans = ##### 2 CommentsShow 1 older commentHide 1 older comment
Amy Topaz on 14 Mar 2022
Thank you so much for detailed explanation