The grid vectors must contain unique points & Error using unique function

1 次查看(过去 30 天)
Hi, I have a range of θ want to put into the equation as below, but it comes out error "The grid vectors must contain unique points". I found out that M would be deplicated when θ >0.024 rad. So, I added the unique function as below, but it still has error "X and V must be of the same length". How should I revise the code?
Before adding unique function:
After adding unique function:
  2 个评论
David Hill
David Hill 2020-8-13
The problem is in your functions calls to interp1 or griddedInterpolant. You need to show more code or use Matlab help to make sure the inputs to these functions are correct.
Kiki Chung
Kiki Chung 2020-8-13
In the interp1 function, X is the theta data and V is the M data. I found that the theta data (R) is 1x61 table while output M data is 1x20 table as shown below. So I was thinking that maybe because of M = unique(moment); it makes the size length of M data reduced. In this case, should I still use unique function?

请先登录,再进行评论。

回答(1 个)

Ayush Gupta
Ayush Gupta 2020-9-3
The unique function returns the same data as is passed inside it but with no reeditions. The moment vector contained some repetition of values. So, when we call unique on moment only the unique values are stored in M. Maybe because in the interp1 function the size of both theta and M vector must be same but which is not the case anyone because unique function is applied on the vector. This the reason why it throws the error. The documentation of unique function can be accessed here.

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by