command window is not working
3 次查看(过去 30 天)
显示 更早的评论
clc;
x=input("Enter the array of x:");
y = input("Enter the array of y:");
n = length(x)
d=zeros(n,n)
for i=1:n
d(i,1)=y(i)
end
for j=2:n
for i=j:n
d(i,j)=d(i,j-1)-d(i-1,j-1);
end
end
fprintf("Difference table\n")
disp(d)
1 个评论
回答(1 个)
Mann Baidi
2024-5-8
编辑:Mann Baidi
2024-5-8
I am assuming here that you are facing issue while taking an array as an input from the user using the command window.
For taking user input as an array the syntax is in the form of '[x y z a b c]'.
Otherwise, If you know the length of the input array you can use a 'for' loop for taking the user input for each element in the array.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Programming Utilities 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!