Info

This question is closed. Reopen it to edit or answer.

I can't figure out why x_array(i) isn't being assigned as a variable

1 view (last 30 days)
if true
% code
end
clear;
clc;
i=1
angle_radians = 0;
num = input('Enter the number of terms to calculate(20 to 100):');
while num <= 19 || num > 100
if num <= 19
fprintf('You entered: %s, too few terms\n',num);
end
if num > 100
fprintf('You entered: %s, too many terms\n', num);
end
num = input('Enter the number of terms to calculate(20 to 100):');
while i:num
x_array(i) = angle_radians;
y_array(i) = sine_Taylor(angle_radians_radians,terms);
i = i + 1
end
end
plot(x_array(i),y_array(i))
fprintf('Sine function from Taylor series in Fig. 1\n')
fprintf('Sine Taylor series vs. sin Matlab function in Fig. 2\n')
fprintf('Program ended\n')

Answers (1)

Star Strider
Star Strider on 7 Apr 2016
I can’t run your code. Changing the nested while condition to:
while i <= num
might be a solution.

This question is closed.

Community Treasure Hunt

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

Start Hunting!