フィルターのクリア

Error using horzcat:: Dimensions of array being concentenated are not consistent

1 回表示 (過去 30 日間)
Mark Sc
Mark Sc 2021 年 3 月 21 日
編集済み: Stephan 2021 年 3 月 21 日
Hi all,
I am running the following but I got that error Dimensions of arrays being concatenated are not consistent.
clearvars;
clc;
S=[.2046e17 .1381e17 .9249e17;.1679e17 .2385e17 1.2332e17;-2.5339 2.5339 2.7582;2.5339 -2.5339 2.75]
m_idx = [min(S(S>0)), find(S==min(S(S>0)))]
I only need min value and index of such value (can I have the first lowest possible value with it's index ??
Any help

回答 (2 件)

Image Analyst
Image Analyst 2021 年 3 月 21 日
This is a FAQ, so please read the FAQ document. It will tell you in more detail everything we'd tell you.

Stephan
Stephan 2021 年 3 月 21 日
編集済み: Stephan 2021 年 3 月 21 日
There are 2 times the same values at different indices. To get only the first occourence:
S=[.2046e17 .1381e17 .9249e17;.1679e17 .2385e17 1.2332e17;-2.5339 2.5339 2.7582;2.5339 -2.5339 2.75]
m_idx = [min(S(S>0)), find(S==min(S(S>0)),1)]
or like i commented in your question before use a function to get all indices where the positive minimum value occours:
S=[.2046e17 .1381e17 .9249e17;.1679e17 .2385e17 1.2332e17;-2.5339 2.5339 2.7582;2.5339 -2.5339 2.75]
[m, idx] = myFun(S)
function [m, idx] = myFun(S)
m = min(S(S>0));
idx = find(S==min(S(S>0)));
end

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by