How to count the maximum and minimum range of non-zeros elements?

let’s suppose we have A of length 50 rows

how we can calculate the maximum range of non-zeros element and as well as minimum

A = [0 0 1 1 1 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 ]

In this case Max and Min should be,

Max = 5

Min = 2

Is there a straightforward solution to do this? without using complex looping because in my case data is too large approximately length of A is 220079705, your kind consideration will be highly regarded by all means,

ANSWER

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

A = [0 0 1 1 1 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 ] props = regionprops(logical(A), ‘Area’); allLengths = [props.Area]; minLength = min(allLengths) maxLength = max(allLengths)

--

--

--

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Web Scraping Example in Python using BeautifulSoup

Project review code exercise

School and More School

Daily Announcement 11/4/21

Thoughts On A New Distributed Systems Language (or languages)

Understanding the basics of OOPs

Website UI Testing — A Complete Guide

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Technical Source

Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

More from Medium

How can I design a PID Controller to stabllize the plant 1/(s³+1) ?

Update Set In Python

JS-04 — JavaScript for Programmers, Chapter 3, Summary, Part1, 10 Points

Skiing — February 2015 — Park City, Utah — Day 2: Skiing the Canyons Ski Area (formerly Wolf…

The view from Cloud Dine — Canyons Ski Area, Park City, Utah