Info

此问题已关闭。 请重新打开它进行编辑或回答。

could anyone help me to solve the error in the following code

2 次查看(过去 30 天)
code:
clc;
A_mas=1:8
for s=1:numel(A_mas)
A=partitions(A_mas,1-s,2)
B=0;
while ~isempty(A)
B= B+1;
if B>numel(A)
idx=1;
B=1;
else
idx=[1 (numel(A)-B+2):numel(A) ];
end
C=A(idx)
A(idx)=[];
end
end
If i run the code i am getting error stating Error using partitions Too many input arguments.
Error in line A=partitions(A_mas,1-s,2). Could anyone please help me on this.
  2 个评论
Torsten
Torsten 2018-9-6
编辑:Torsten 2018-9-6
What do you expect A to be when you execute
A=partitions(A_mas,1-s,2)
?
"partitions" is called with at most two arguments, not three.
jaah navi
jaah navi 2018-9-6
for the code:
code:
clc;
A_mas=1:3
for s=1:numel(A_mas)
A=partitions(A_mas,1-s,2)
B=0;
while ~isempty(A)
B= B+1;
if B>numel(A)
idx=1;
B=1;
else
idx=[1 (numel(A)-B+2):numel(A) ];
end
C=A(idx)
A(idx)=[];
end
end
I can have 5 partitions {1 2 3} {1 2} {3} {1 3} {2} {1} {2 3} {1} {2} {3}
I want to have the 1st partition to be displayed as
1 2 3
2nd partition to be 1 2
3
3rd partition to be 1 3
2
4th partition to be 1
2 3
5th partition to be 1
2
3
could you please help me onthis.

回答(0 个)

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by