MATLAB: I want to create a function z=f(a,b)..how can I create like this using the below code functions if truea=Ns;b=8;if ~mod(a,b) z=0else z=b-mod(a,b);endend Best Answer MATLAB documentation tells you how to make functions. Like, to make your "f" function you'd do this:function z = f(a, b)if ~mod(a,b) z=0else z=b-mod(a,b);endTo call it, you'd do this:a = Ns;b = 8;z = f(a, b) Related SolutionsMATLAB: How to use””\langle〈 and \rangle 〉 “” in matlab bin2dec(char('0'+reshape(bits, 8, 24).'))... but what does this have to do with the angle brackets? MATLAB: I have an error on the following code.how to rectify the error function z = myfunction(Ns)c = Ns;d= 8;z = f(c, d)endfunction z = f(c,d)if ~mod(c,d) z=0else z=d-mod(c,d);endendCall the function:Ns = rand ; % any valuez = myfunction(Ns) ; Related QuestionNeed Help Plotting Mode ShapesError in Matlab – “() Indexing must appear last in an index expression”
Best Answer