Answered
Creation of matrices (24,72) M1&M2 ?
You can use <http://www.mathworks.com/help/matlab/ref/blkdiag.html |blkdiag|>: C1 = repmat({[1,1,0]},1,24); M1 = blkdiag...

11 years ago | 0

| accepted

Answered
What is an alternative FIND function that find indices and values of both ZERO and NONZERO elements in Matlab ?
>> E = [2, 0, 5, 9]; >> [R,C] = ind2sub(size(E),1:numel(E)) R = 1 1 1 1 C = 1 2 3 4 Or usi...

11 years ago | 0

| accepted

Answered
hi..lets say there i a vector x=[1:3:50]..how can i find closest number to 25 in this vector using find??
>> val = 26; >> vec = 1:3:50; >> [~,idx] = min(abs(vec-val)); >> vec(idx) ans = 25

11 years ago | 1

| accepted

Answered
Error with using xlsread on 9000 files
Here is one way of reading semi-colon delimited <https://en.wikipedia.org/wiki/Comma-separated_values CSV> [sic] files quickly u...

11 years ago | 1

| accepted

Answered
Code for extracting the special values
% Read original data file: M = dlmread('remaining particles total.txt','\t'); H = min(M(:,1)):max(M(:,1)); [X,Y] = is...

11 years ago | 0

| accepted

Answered
How can I take the values of one array as inputs to check a condition for another array?
You can use <http://de.mathworks.com/help/matlab/ref/sub2ind.html |sub2ind|> to convert the row and column indices to linear ind...

11 years ago | 1

| accepted

Answered
Matrix reduction to see how many various elements the matrix has
You could use <http://www.mathworks.com/help/matlab/ref/unique.html |unique|> with the |'stable'| option: >> A = [4, 0, 0, ...

11 years ago | 0

| accepted

Answered
How to show all jpg images saved in MATLAB folder?
This displays all of the |jpg| images in the current directory: S = dir('*.jpg'); for k = 1:numel(S) figure(); ...

11 years ago | 0

| accepted

Answered
How do I divide a 3X3 matrix in three vertical or horizontal one-dimensional vectors using a FUNCTION?
Here are some ideas for you, using this sample matrix: >> X = reshape(1:9,3,3) X = 1 4 7 2 5...

11 years ago | 0

Answered
Replacing specific values in each matrix row in all values in the matrix
Try this: A = [8 66 92 101 0; 14 52 80 76 0; 16 66 33 51 7; 1 76 66 0 0] % get unique elements, row-wise: [~,X,Y] = u...

11 years ago | 0

| accepted

Answered
how to convert 2*2 matrix into 256*256 matrix using for loop.
Just use <http://de.mathworks.com/help/matlab/ref/repmat.html |repmat|>, it is much neater and faster than using a loop: >>...

11 years ago | 0

Answered
how to return two results by one output when using arrayfun()?
*Solution 1: You actually don't need |arrayfun| at all.* The simplest, neatest and fastest MATLAB code uses <http://de.mathwo...

11 years ago | 1

| accepted

Answered
Problem with an equation
Presumably you are not intending to perform <http://www.mathworks.com/help/matlab/ref/mtimes.html matrix multiplication>, but ra...

11 years ago | 1

| accepted

Answered
How can i generate multiple values?
Ugh... this is a really bad idea! Avoid creating dynamically named variables in MATLAB. This is poor practice as has been exp...

11 years ago | 0

| accepted

Answered
How do I generate multiple sets of arrays automatically?
Here is your code, with a small change to store the data values in matrices: M = 10; % number of repetitions N = 30; %...

11 years ago | 0

| accepted

Answered
How to replace new line with white space in text documents
str = regexprep(test1,'\s+',' '); or str = regexprep(test1,'[\n\r]+',' ')

11 years ago | 5

| accepted

Answered
How to make my own custom colormap?
*Step 1: Convert HEX to Decimal* >> hex = ['#f8fe34';'#f4771e';'#d94015';'#148b3e';'#085a3f';'#41332d';'#010101'] hex =...

11 years ago | 11

| accepted

Answered
Can I plot semilogx, semilogy, loglog plots simultaneously by writing in code in a single m file?
You could use <http://www.mathworks.com/help/matlab/ref/figure.html |figure|> to create three separate figures: x = linspac...

11 years ago | 0

| accepted

Answered
Sort a matrix in a specific format
>> A = [ 4, 0, 0, 1, 2; 11, 0, 0, 20, 1] A = 4 0 0 1 2 11 0 0 20 1 >> X = all(A...

11 years ago | 0

| accepted

Answered
How to determine the number of iteration steps upon using "nlinfit"
One conceptually simple solution is to define your own |OutputFcn| and specify this in the <http://de.mathworks.com/help/stats/s...

11 years ago | 0

| accepted

Answered
how can I reduce the execution time of the given code?
After adding <http://de.mathworks.com/help/matlab/matlab_prog/symbol-reference.html#bsgigzp-46 semicolons> to all of the lines I...

11 years ago | 2

| accepted

Answered
Deleting duplicate rows and keeping zero rows?
A=[1 2; 3 4; 0 0; 1 2; 5 6; 0 0] X = ~any(A,2) [~,Y] = unique(A(~X,:),'rows','stable') ...

11 years ago | 1

| accepted

Answered
Bundle Funtions inside a Script
The easiest option is to turn the script into a function, and then put all of the other functions in the same Mfile. Doing this ...

11 years ago | 0

| accepted

Answered
Check if a function input exists in workspace
The fastest and most reliable way to check which inputs have been provided is to use <http://www.mathworks.com/help/matlab/ref/n...

11 years ago | 2

Answered
how to insert rows and colums of zeroes in this matrix ??? a=[1 2 3;4 5 6]
Here is one quick way to interlace columns and rows of zeros: >> a=[1 2 3;4 5 6]; >> b = zeros(2*size(a)); >> b(1:2:e...

11 years ago | 0

| accepted

Answered
Creating 3D matrix from a vector with special order of elements without using a loop command
>> R = 2; %rows >> C = 3; %columns >> P = 1:6; >> Q(R,C,:) = P; >> size(Q) ans = 2 3 6 This places...

11 years ago | 1

| accepted

Answered
How to rearrange data in matrix rows
<http://www.mathworks.com/help/matlab/ref/reshape.html |reshape|>, like pretty much all MATLAB operations, works columnwise. So ...

11 years ago | 0

| accepted

Answered
create number of arrays dynamicly
*Do NOT create arrays dynamically.* Creating arrays dynamically is a really bad way to program. Read this to know why: <http:...

11 years ago | 0

Answered
Iterate though a matrix with repeated values and preform operations on corresponding columns.
There are multiple issues with your code, but they all boil down to the superfluous looping over rows and columns. Doing so mean...

11 years ago | 2

| accepted

Answered
find .mp3 and .wav files in folder
S = [dir('*.mp3');dir('*.wav')] N = {S.name} for k + numel(N) N{k} % name of file .. your code end

11 years ago | 1

Load more