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..
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
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...
Antworten (2)
Wayne King
am 4 Aug. 2013
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
Azzi Abdelmalek
am 4 Aug. 2013
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
Diese Frage ist geschlossen.
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!