- You should not name one of your variable "range" as it is the name of an existing function.
- length(50) in the outer FOR loop is not 50 but 1; I guess that you wanted for i=1:50 actually.
- if r==1 end does nothing. If you want to quit the loop if r is 1, you want to implement use BREAK in the statement: if r==1, break; end.
- The inner FOR loop uses the same loop index variable i as the outer FOR loop; this cannot work (both loops will interfere), so you'll want to change it for e.g. k.
- Don't clear all within your function, it will clear the input args p and q.
hello professionals ..i have aattached my code plz suggest me why it is not displaying value of kp2 and e
1 view (last 30 days)
Show older comments
kp2=rand(10);
e=rand(10);
for i=1:length(50)
r=e(i)*dp-kp1*kp2(i)*(p-1);
if r==1
break;
end
end
here dp , kp1 and p are previously calculated.in this code value come in fraction and it doesnot enter the for if loop...plz suggest me code
0 Comments
Accepted Answer
Cedric
on 12 Apr 2013
Edited: Cedric
on 12 Apr 2013
Where do you define M ? At this point it crashes because M is undefined.
A few additional points:
EDIT: thank you Walter for the edition, I hadn't seen that it was a function.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!