I have an error on the following code.how to rectify the error ?

3 次查看(过去 30 天)
if true
clc;
clear all;
close all;
c = Ns;
d= 8;
z = f(c, d)
function z = f(c,d)
if ~mod(c,d)
z=0
else
z=d-mod(c,d);
end
end
end

采纳的回答

KSSV
KSSV 2018-1-22
function z = myfunction(Ns)
c = Ns;
d= 8;
z = f(c, d)
end
function z = f(c,d)
if ~mod(c,d)
z=0
else
z=d-mod(c,d);
end
end
Call the function:
Ns = rand ; % any value
z = myfunction(Ns) ;
  1 个评论
PLACEIUS NISHIGA G
PLACEIUS NISHIGA G 2018-1-22
Thank you sir.still I have a error likr this.
Error: File: file.m Line: 104 Column: 1
Function definitions are not permitted in this context.
how to clear this error?

请先登录,再进行评论。

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by