bug in the function
显示 更早的评论

What do I need to write in f2 (u1, u2) so that I do not have the error :
Undefined function or variable 'ETA'.
回答(1 个)
Cris LaPierre
2021-1-14
0 个投票
What is ETA?
You cannot use a variable you have not defined. Perhaps you think this variable is loaded by data.mat, but apparently not.
7 个评论
Image Analyst
2021-1-14
Or else, you need to pass ETA into f2(). f2 is not going to magically know what ETA is unless you tell it.
yonatan friedman
2021-1-14
编辑:yonatan friedman
2021-1-14
Image Analyst
2021-1-14
Please attach data.mat and all m-files that are needed to run your code. I'll check back later.
yonatan friedman
2021-1-15
编辑:yonatan friedman
2021-1-15
Cris LaPierre
2021-1-15
The problem is when your for loop counter is 7, the value of d in f4 is a single number. However, in computing ETA, you use d(end-1). Since there is only a single value, end-1=0, which causes the error that you see.
Cris LaPierre
2021-1-15
These types of errors are difficult if not impossible to spot by just inspecting your code. The best way to track down the issue is to learn how to use the debugger.
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!