could anyone help me to solve the issue in the following code
Accepted Answer
More Answers (2)
9 Comments
@jaah navi: your code:
for t=1:length(X) % <- first FOR
A = partitions([X(t)])
for d=1:length(A) % <- second FOR
if length(A{d}) <= 2 % <- the IF statement
Walter Roberson wrote: "...the if needs to be after the first for but before the second for."
Question: Is the IF after the first FOR?
Answer: Yes.
Question: Is the IF before the second FOR?
Answer: No. You put it in the wrong location.
@jaar navi: you have been using MATLAB for more than a year, so what do you expect this to achieve?:
if length(A{d}) <= 2
end
An IF statement with nothing in it, does that really seem useful to you? Do you imagine that Walter Roberson wanted you to put an empty IF statement into your code, one that does absolutely nothing?
I am sure that you are capable of thinking about this, if you actually tried... Hint: you were told to put the IF between the two FOR loops... think about where the other END should go. Experiment! Your computer will not explode if you experiment.
@jaah navi: and you are too busy to read the length documentation, or actually try the code that Walter Roberson told you to use?
2 Comments
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!