Sorting a cell of strings using a certain character position

I have a variable called var=

vart=[{‘Ice011_L_3of3m.mat’’}; {‘Ice011_P_1of3m.mat’} ;{‘Ice011_P_2of3m.mat’}]

We would need to sort the strings in the cell array using the 10th character of each string, so we would get the following result

var_sorted =[{‘Ice011_P_1of3m.mat’}; {‘Ice011_P_2of3m.mat’} ;{‘Ice011_L_3of3m.mat’}]

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.

Simpler in two lines:

vart = {'Ice011_L_3of3m.mat';'Ice011_P_1of3m.mat';'Ice011_P_2of3m.mat'}
[~,idx] = sort(cellfun(@(v)v(10),vart));
vart = vart(idx)

SEE COMPLETE ANSWER CLICK THE LINK

https://www.matlabsolutions.com/resources/sorting-a-cell-of-strings-using-a-certain-character-position.php

--

--

--

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

There are 10 types of people

Webdev from Zero to Hero in 3–6 months? You have to be agile! (3 of 3)

Last day as Seniors at Makers Academy — We did it!!

Write Your Own C-extension to Speed Up Python by 100x

Oracle BPM Interview Questions

My emails with Ayndryl

Day6, LaserCount

Implementing an Enterprise IoT Solution for Manufacturing

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 to run python file in MatLab via script?

02 Chain of Reasoning in the Development of Bioinformatics Tools and The Power of Gene Sequences

Find whether (0,0) lies inside a triangle or not (2-axis)

String Theory of Python