Why this not works..?

n = 10;
for p = 1:n
lal(p)
end
function [] = lal(p)
.
.
.
This method doesn't work.. Why..?

 采纳的回答

What does not work about it? What error message is given?
One thing I notice is that in the code you show, if that is the entire code, then you are attempting to define a function inside a script. You need to convert the first part to a function. For example,
function testloop
n = 10;
for p = 1 : n
lal(p)
end
function [] = lal(p)
...

4 个评论

Lalit Patil
Lalit Patil 2012-12-21
编辑:Lalit Patil 2012-12-21
This is the link for the function myFunction.m which i am using..
But now i want loop for imageNumber.. I have to use this function in GUI button. So, what modification i have to do..?
What happened when you tried?
d = dir('.');
n = length(d)-2;
for imageNumber = 1:n
myFunction(imageNumber)
end
It works now..
Problem get solved..
Then officially mark it as solved. Looks just like what Walter said except that the function name is different.

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by