Can someone tell me what is wrong with my code, and any corrections to be made?

The problem lies within newton_basic, i receive an error that dimensions do not match, however, i do not know how to fix the issue.

4 件のコメント

Greg
Greg 2018 年 4 月 4 日
Which line is the error?
Raiven Balderas
Raiven Balderas 2018 年 4 月 4 日
編集済み: Raiven Balderas 2018 年 4 月 4 日
errors lie in line 14 of newton_simple.m
and line 20 of newton_basic.m
however newton_simple.m is perfect as it is... I need to get newton_basic.m to work....
Tarsem Singh Khalsa
Tarsem Singh Khalsa 2018 年 4 月 4 日
What is the function of j in for loop of newton_simple
Raiven Balderas
Raiven Balderas 2018 年 4 月 4 日
im not sure.... i just need help fixing the "matrix dimensions must agree"
I dont know how to go about fixing it

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

回答 (1 件)

Guillaume
Guillaume 2018 年 4 月 4 日

0 投票

"I dont know how to go about fixing it"
The best way is to learn how to use the debugger. In this instance, issuing dbstop if error and looking at the states of the variables and experimenting at the command line when the program breaks into the debugger because of the error would show you the problem.
The problem is simple, your newton_simple.m code expects two functions f and df that returns a scalar value given a scalar input. Your df function does not return a scalar value when given a scalar input because that's polyder does not return scalar values. I suspect you never meant to use polyder but who knows?

カテゴリ

タグ

質問済み:

2018 年 4 月 4 日

回答済み:

2018 年 4 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by