Error using horzcat:: Dimensions of array being concentenated are not consistent
1 view (last 30 days)
Show older comments
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
0 Comments
Answers (2)
Image Analyst
on 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.
0 Comments
Stephan
on 21 Mar 2021
Edited: Stephan
on 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
0 Comments
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!