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

1 visualizzazione (ultimi 30 giorni)
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

Risposte (2)

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

Stephan
Stephan il 21 Mar 2021
Modificato: Stephan il 21 Mar 2021
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

Categorie

Scopri di più su Convert Image Type in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by