Clear Filters
Clear Filters

Info

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

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

2 views (last 30 days)
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 Comments
Torsten
Torsten on 6 Sep 2018
Edited: Torsten on 6 Sep 2018
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 on 6 Sep 2018
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.

Answers (0)

This question is closed.

Tags

Community Treasure Hunt

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

Start Hunting!