Convert vector to array
显示 更早的评论
Hello, I need to convert a "n-by-2 column vector of [x y] pairs" into a "n-by-2 array of [x y] pairs". I did try the reshape and selector functions without any success, can someone help me?
In details : I use the findpath function to give me a number n of waypoints to go from a start point to a goal point, it returns a n-by-2 column vector. I need to link these points to a controllerPurePursuit block which takes a n-by-2 array as an input. When linked directly on Simulink, I get this error :
- Expected waypoints to be an array with number of columns equal to 2.
Thank you very much
8 个评论
"n-by-2 column" doesn't make sense. A column, by definition, is n-by-1. Are you describing an nx1 cell array where each element contains a 1x2 vector?
"array " is a generic term. There are cell arrays, matrices are arrays, there are structure arrays etc. Maybe you could give an explicit input/output example.
Bandar
2019-12-15
May be you need to elaborate a bit more. Array and vector are terms used interchangeably in Matlab.
Pierre FEHLEN
2019-12-15
Adam Danz
2019-12-15
path is already an nx2 array.
Pierre FEHLEN
2019-12-15
Adam Danz
2019-12-15
path does have 2 columns. Something's not adding up.
Image Analyst
2019-12-15
Maybe that's the problem. path is a very important globa variable and evidently you overwrote it with some variable of yours. That is likely to cause some problems. DON'T name your variables after built in variables or function names.
If x is a column vector that you already have, and y is a column vector and your other function needs an N-by-2 array of values where each row is a corresponding (x,y) pair, then you can simply create a new matrix called xy
xy = [x, y];
and pass that into your function.
Marco Soriano
2022-5-3
Hi, did you ever solve the problem?
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!