Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
Mark Sc
Mark Sc le 21 Mar 2021
Modifié(e) : Stephan le 21 Mar 2021
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

Réponses (2)

Image Analyst
Image Analyst le 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 le 21 Mar 2021
Modifié(e) : Stephan le 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

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by