function x=solv(a,b) while round((a*x​-1)/b)~=(a​*x-1)/b x=x+1; end this function is showing error while running: ??? Undefined function or method 'solv' for input arguments of type 'double'. please help me to solve this problem..

function x=solv(a,b)
while round((a*x-1)/b)~=(a*x-1)/b
x=x+1;
end
above function is showing error while running: ???
Error is: Undefined function or method 'solv' for input arguments of type 'double'.
please help me to solve this problem...

Réponses (2)

The error message your getting is because solv.m is not in a folder (directory) on the MATLAB path.
Let's say that you have your solv.m in a folder called c:\mfiles. You must do the following, either:
>>addpath 'c:\mfiles'
or enter
>>pathtool
and add the folder using the UI.
If you have done it successfully, you should be able to enter:
>>which solv.m
and get the path back to your M-file returned.
However, even then your function will error:
Your while statement references a variable, x, but you never define x in your function prior to using it, nor do you pass x as an input to the function.
The function will error saying that x is undefined
In this line
while round((a*x-1)/b)~=(a*x-1)/b
What is the value of x? your code is supposed to calcul x

Cette question est clôturée.

Produits

Clôturé :

le 20 Août 2021

Community Treasure Hunt

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

Start Hunting!

Translated by