Solved


Removing rows from a matrix is easy - but what about inserting rows?
Assume A is a 5-by-5 matrix. A([2,4],:) = [] is a quick way to remove rows 2 and 4. Can you find a quick way to insert rows into...

6 years ago

Solved


N-Dimensional Array Slice
Given an N-dimensional array, _A_, an index, _I_, and a dimension, _d_, return the _I_ th elements of _A_ in the _d_ dimension. ...

6 years ago

Solved


Permute diagonal and antidiagonal
Permute diagonal and antidiagonal For example [1 2 3;4 5 6;7 8 9] -> [3 2 1;4 5 6;9 8 7] WITHOUT diag function (and variable n...

6 years ago

Solved


Matrix with different incremental runs
Given a vector of positive integers a = [ 3 2 4 ]; create the matrix where the *i* th column contains the vector *1:a(i)...

6 years ago

Solved


Rotate input square matrix 90 degrees CCW without rot90
Rotate input matrix (which will be square) 90 degrees counter-clockwise without using rot90,flipud,fliplr, or flipdim (or eval)....

6 years ago

Solved


Set some matrix elements to zero
First get the maximum of each *row*, and afterwards set all the other elements to zero. For example, this matrix: 1 2 3 ...

6 years ago

Solved


Make an awesome ramp for a tiny motorcycle stuntman
Okay, given a vector, say v=[1 3 6 9 11], turn it into a matrix 'ramp' like so: m=[1 3 6 9 11; 3 6 9 11 0; 6 9 ...

6 years ago

Solved


surrounded matrix
With a given matrix A (size m x n) create a matrix B (size m+2 x n+2) so that the matrix A is surrounded by ones: A = [1 2 ...

6 years ago

Solved


Reverse the elements of an array
Reverse the order of elements in an array: eg: input X = [ 1 2 3 ; 4 5 6 ; 7 8 9 ] o...

6 years ago

Solved


Flip the main diagonal of a matrix
Given a n x n matrix, M, flip its main diagonal. Example: >> M=magic(5); >> flipDiagonal(M) 9 24 1 ...

6 years ago

Solved


Back to basics 23 - Triangular matrix
Covering some basic topics I haven't seen elsewhere on Cody. Given an input matrix, return a matrix with all elements above a...

6 years ago

Solved


Remove NaN ?
input -> matrix (n*m) with at least one element equal to NaN; output -> matrix(p*m), the same matrix where we deleted the enti...

6 years ago

Solved


Back to basics 21 - Matrix replicating
Covering some basic topics I haven't seen elsewhere on Cody. Given an input matrix, generate an output matrix that consists o...

6 years ago

Answered
How to align two different sets of data whilst allowing a +- 10% range?
Hi)) %converting and renaming of variables t=table2array(table1); m=matrix2; %0.1 - range of choosing d=1+0.1*[...

6 years ago | 1

| accepted

Answered
Find the index of a string is structure
As i understand you right, the field textdata contains cell array with some strings. Let figure that |A| - structure. Then if y...

6 years ago | 1

| accepted

Answered
How to count continuous non zero elements whilst keeping the date of the first non-zero value
Hi. It's the simplest but not the shortest code for this problem. k=A(1,6)~=0; for i=1:size(A,1) if A(i,6)~=0&...

6 years ago | 1

| accepted

Answered
GA is not working...Function i have written separately calling in main program but not worked??
There are two version of code which are working but do not converge. First: xdata =[ 1 2 3 4 5 6] ; ydata=(1./(xd...

6 years ago | 0

| accepted

Answered
How can I put the values that I made in a for and if loop into a vector?
Code improvements: %Range of i for different calculation formulas FirstRange=[1:L_1]; SecondRange=[L_1:L]; %Create...

6 years ago | 0

Answered
merging two text files and generate 1000 copies of the new text (or dat) file
You should to read help for <https://www.mathworks.com/help/matlab/ref/sprintf.html sprintf> and <https://www.mathworks.com/help...

6 years ago | 1

| accepted

Answered
I can't open .fig files .m files nothing
You should to click on the "Browse" button and specify the path to your matlab program file which may be "C:\Program Files\MATL...

6 years ago | 0

| accepted

Answered
could anyone tell me how to have equal spacing of selected numbers with respect to axis.
You can compress data between 2 and 23 ticks roughly by %before plotting XData(XData>2&XData<23)=(XData(XData>2&XData<23)-...

6 years ago | 0

Answered
What does the ω_r represent in the Mechanical System Equation provided in the Permanent Magnet Synchronous Machine
Hello, That is also mechanical speed because that is equation of mechanical speed. Maybe in the full system of equations of S...

6 years ago | 0

Question


Error is occured when I changed version of Matlab
I have a lot of the code which work correctly in the Matlab 2013b but when I tried evaluate it on the machine with Matlab 2016a ...

6 years ago | 1 answer | 0

1

answer

Question


Does symbolic function inv() evaluated in multithread?
Hello, as noted here <https://www.mathworks.com/matlabcentral/answers/95958-which-matlab-functions-benefit-from-multithreaded...

6 years ago | 1 answer | 0

1

answer

Solved


Missing five
Convert decimal numbers to a base-9 notation missing the digit *5* <<http://www.alfnie.com/software/missing5.jpg>> Too man...

7 years ago

Solved


Is this is a Tic Tac Toe X Win?
For the game of <https://en.wikipedia.org/wiki/Tic-tac-toe Tic Tac Toe> we will be storing the state of the game in a matrix M. ...

7 years ago

Solved


Pentagonal Numbers
Your function will receive a lower and upper bound. It should return all pentagonal numbers within that inclusive range in ascen...

7 years ago

Solved


Spot the First Occurrence of 5
This problem series invites you to solve two simple problems related to the integer NUMBER FIVE, in order to celebrate <https://...

7 years ago

Solved


I Plead the Fifth
Write a function to provide a yes or no answer to the input string. However, it must plead the 5th amendment (return an empty st...

7 years ago

Solved


Pernicious Anniversary Problem
Since Cody is 5 years old, it's pernicious. <http://rosettacode.org/wiki/Pernicious_numbers Pernicious number> is an integer whi...

7 years ago

Load more