Not enough input arguments.
显示 更早的评论
function [u] = suitem(A,b,u1,nb)
[n,n] = size(A) ;
u=u1 for i = 1 : nb
u= A*u +b
end
end
采纳的回答
Other than having to fix the for being on the same line, it looks okay to me.
suitem(rand(8,8), rand, rand, 7)
ans = 8×8
5.9738 5.7873 6.4540 5.8167 5.9296 5.6976 6.9287 6.5290
6.3011 6.1045 6.8077 6.1355 6.2547 6.0097 7.3086 6.8868
6.9830 6.7651 7.5445 6.7995 6.9317 6.6601 8.0996 7.6322
6.8662 6.6519 7.4183 6.6857 6.8157 6.5487 7.9641 7.5045
7.3179 7.0894 7.9063 7.1255 7.2641 6.9795 8.4879 7.9982
7.8525 7.6073 8.4838 7.6460 7.7947 7.4894 9.1080 8.5824
5.8720 5.6887 6.3441 5.7176 5.8287 5.6005 6.8108 6.4178
5.0072 4.8508 5.4098 4.8755 4.9704 4.7757 5.8077 5.4726
●
function [u] = suitem(A,b,u1,nb)
[n,n] = size(A);
u=u1;
for i = 1 : nb
u= A*u +b;
end
end
5 个评论
thank you walter
function [u] = suite(A,b,u1,nb)
[n,n] = size(A);
u=u1;
for i = 1 : nb
u= A*u +b;
end
end
A=[5/8 -1/4 1/8;1/4 0 1/4;1/8 -1/4 5/8];b=[1;-1;1];u1=[5;2;-4];m=20;p=m;
u=suite(A,b,u1;b)
u must be size [3,20] but i found it [3,1] please help
Why would it be 3 x 20? You create m=20 and you assign that to p, but you do not use m or p in the code.
%{
u=suite(A,b,u1;b)
%}
That is invalid syntax. Assuming you want
%{
u=suite(A,b,u1,b)
%}
then notice that you are passing b twice, and that the second one is in a place you expect a scalar.
I suspect what you want is
A = [5/8 -1/4 1/8;1/4 0 1/4;1/8 -1/4 5/8];
b = [1;-1;1];
u1 = [5;2;-4];
m = 20; p = m;
u = suite(A, b, u1, m)
u = 3×20
5.0000 3.1250 2.9688 3.0859 3.1934 3.2593 3.2953 3.3141 3.3236 3.3285 3.3309 3.3321 3.3327 3.3330 3.3332 3.3333 3.3333 3.3333 3.3333 3.3333
2.0000 -0.7500 -0.5625 -0.0781 0.2617 0.4561 0.5593 0.6125 0.6395 0.6530 0.6598 0.6633 0.6650 0.6658 0.6662 0.6665 0.6666 0.6666 0.6666 0.6667
-4.0000 -1.3750 0.7188 1.9609 2.6309 2.9780 3.1547 3.2437 3.2885 3.3109 3.3221 3.3277 3.3305 3.3319 3.3326 3.3330 3.3332 3.3332 3.3333 3.3333
●
function [u] = suite(A,b,u1,nb)
[n,n] = size(A);
u = u1(:);
for i = 2 : nb
u(:,i) = A * u(:,i-1) + b;
end
end
thank you this is what i want
Walter,check please https://fr.mathworks.com/matlabcentral/answers/716073-hilbert-matrix-come-on
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Characters and Strings 的更多信息
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
