MATLAB 2008b Compatable alternative.

I'm using the following function to find the index of an array closest to the value passed. The function doesn't seem to be compatible with v.2008b. I need a function that does the same thing but is compatible. v.2008 is the only version that is compatible with HSPICE.
function[index]=closeindex(value,array)
[~,index]=min(abs(array-value));
end

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2011 年 8 月 29 日

0 投票

The incomparable part is probably the ~ symbol. You can change that line to be:
[trash,index]=min(abs(array-value));

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

質問済み:

2011 年 8 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by