Matlab coding errors call when run..Please help to solve this problem

%Ingredients
f = input('Enter your function: ');
df = input('Enter derivative of this function: ');
e = input('Enter tolerance: ');
x0 = input('Enter initial guess: ');
n = input('Enter no. of iteration: ');
%processing
if df(x0)~=0
for i=1:n
x1 = x0 - f(x0)/df(x0);
fprint ('x%d = %', 20f\n', i, x1)
if abs(x1-x0)<e
break
end
if df(x1)==0
disp('Newton raphson failed')
end x0 = x1;
end
end

3 件のコメント

the cyclist
the cyclist 2023 年 1 月 9 日
@FAKHRULRAZI, I edited your post to put it into CODE format.
Can you give us sample inputs to use, that result in the error you see? (Even better is to just code them in, instead of having us go through inputs.)
What is the full error message you are getting?
FAKHRULRAZI
FAKHRULRAZI 2023 年 1 月 9 日
Walter Roberson
Walter Roberson 2023 年 1 月 9 日
apostrophe is not a valid character in a file name for a m file.

サインインしてコメントする。

回答 (2 件)

Gowthami
Gowthami 2023 年 1 月 18 日

0 投票

Hi,
It is my understanding that you are getting the error "MATLAB can only run a file with a valid name" while running a script.
As your script name contains an apostrophe, you are getting this error.
File names must start with a letter, and can contain letters, digits, or underscores.
More information on specifying the file name can be found here: https://in.mathworks.com/help/matlab/matlab_env/specify-file-names.html
Adrian
Adrian 2024 年 10 月 8 日

0 投票

Unable to run file.
MATLAB file names must start with an alphabetic character and can contain up to 63 alphanumeric characters or underscores.

3 件のコメント

Adrian
Adrian 2024 年 10 月 8 日
移動済み: Walter Roberson 2024 年 10 月 8 日
Exercise_2
Error using count
Not enough input arguments.
Error in Exercise_2 (line 4)
[V,A] = size(count)
^^^^^
Adrian
Adrian 2024 年 10 月 8 日
移動済み: Walter Roberson 2024 年 10 月 8 日
Exercise_2
Error using count
Not enough input arguments.
Error in Exercise_2 (line 4)
[V,A] = size(count)
^^^^^
Walter Roberson
Walter Roberson 2024 年 10 月 8 日
Your Exercise_2 has been defined as a function that requires at least one input parameter, referred to as count but you are trying to run the function without providing any input.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeQuadratic Programming and Cone Programming についてさらに検索

製品

リリース

R2022b

タグ

質問済み:

2023 年 1 月 9 日

コメント済み:

2024 年 10 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by