Answered
How to create a string with names that differ, without a loop?
The fastest solution is to use the undocumented function sprintfc: sprintfc('K%d',1:39) As this is undocumented, use at your o...

8 years ago | 1

| accepted

Answered
How to concatenate tables with the same number of variables but different number of rows?
Assuming that the data have the same class, that each .mat file contains the same four variables, and that within any one mat fi...

8 years ago | 0

Answered
How do I use two arrays to lookup the value from a third array?
Here is a general solution based on sub2ind, for any row and column indices: >> row = 1:10; >> col = 10:-1:1; >> mat = rand(1...

8 years ago | 0

| accepted

Answered
How to index this matrix ?
Several years ago I wrote an efficient function that returned the linear indices corresponding to any ND indices returned by min...

8 years ago | 0

Answered
How do I flip the order of cells in a cell array?
Simpler: C(end:-1:1) = C(:) or C = flip(C)

8 years ago | 5

Answered
combining specific elements in an array
Assuming that the number of digits is always the same.... Method one: reshape and matrix multiply: >> V = [16, 29, 0.599, 16, ...

8 years ago | 0

| accepted

Answered
finding the increase in values
a = [2;2;2;3;3;3;5;5;5;4;4;3;3;3;2;2;3;3;3;4;4;4;5;5;5;4;4;3;3] idx = [true;diff(a)~=0]; idy = diff(a(idx))>0; idd = diff([0;...

8 years ago | 0

| accepted

Answered
generating matrices of the possible combinations
X = [1,7,9,10,15;4,8,5,9,21;2,14,3,6,16] P = nchoosek(1:5,3) N = size(P,1); C = cell(1,N); for k = 1:N C{k} = X(:,P(k,:...

8 years ago | 1

| accepted

Answered
User defined function with vector inputs returns incorrect values?
if length(n) > 1 ... return % add this! end The reason is simple: you detect when n is non-scalar, and inside that ...

8 years ago | 0

| accepted

Answered
How to calculate the memory required by struct, numerical and char arrays? Kindly share the formula?
The documentation explains how much memory is required for cell arrays and structure arrays: https://www.mathworks.com/help/mat...

8 years ago | 1

Answered
Why does 7*(0.1) - 0.7 = 1.1102e-16 whereas 9*(0.1)-0.9 =0 in MATLAB?
Those values that you are computing with cannot be exactly represented using binary floating point numbers. What you see printed...

8 years ago | 4

Answered
Hello.......i have a matrix.......what i wonaa do is count the repeated entries in column 2 first then make arrangement =(number of repeated termes)! ..for example in given matrix i have two repeated terms so first arrangmnt..1 2 3 the second 2 1 3
Interesting problem. I used a slightly more complex example, with two values duplicated (4 twice, 9 thrice), for which we would ...

8 years ago | 1

| accepted

Answered
How to skip [] when add values to a vector variable?
str = input('Enter values x y: ','s'); vec = sscanf(str,'%f')

8 years ago | 0

Answered
How do I create a for loop that can use multiple changing variables?
... b = 0:pi/80:pi/8; c = 0:pi/40:pi/4; d = 0:3*pi/80:3*pi/8; e = 0:pi/20:pi/2; for k = 1:numel(b) pause(0.5) B =...

8 years ago | 0

| accepted

Answered
How to change one row vector into many row vector matrix?
V = rand(1,12096); S1 = [24,24,6]; A1 = reshape(V(1:prod(S1)),S1); % size 24x24x6 S2 = [24,36,10]; A2 = reshape(V(prod(S1)+1...

8 years ago | 0

| accepted

Answered
Is there any command to change one pixel of an RGB image ?
Just use indexing: I1(100,100,:) = [10,180,5] Or for each color separately: I1(100,100,1) = 10; I1(100,100,2) = 180; I1(100...

8 years ago | 0

Answered
How to improve speed ?
A = 0.005:0.00005:0.03; N = numel(A); M1 = nan(N,4); % max M2 = nan(N,4); % min for k = 1:N ... p = round(max(size...

8 years ago | 0

Answered
How to produce and save in a variable a list of a folder's files?
Do NOT use cd unless you want to force yourself into writing slow hard-to-debug code. It is better to use a full path name: D =...

8 years ago | 0

Answered
Convert cell array to an array, when the size of the cells is different
Download padcat: https://www.mathworks.com/matlabcentral/fileexchange/22909-padcat-varargin and use it like this: >> M = padc...

8 years ago | 1

| accepted

Answered
I am confused as to how incorporate a value from another function in a different script, into this one where the y variable is now the input. The actual problem is below. Please show me how to solve this, and why.
The proper MATLAB solution would be to vectorize your code, which efficiently allows for the input to be an array of any size. F...

8 years ago | 0

| accepted

Answered
variable number of outputs
It appears that you want to do something like this: function out = polyargout(x) if x>1 out = arrayfun(@magic, 1:x, 'unif...

8 years ago | 0

| accepted

Answered
Let user choose the name and extension of his file
uiputfile

8 years ago | 0

| accepted

Answered
whats wrong with my code?
Make pdefun and pdebc nested functions by defining them inside of ped1: function ped1() ... V = ... D = ... R = ... ... ...

8 years ago | 0

| accepted

Answered
How to count the number of filled elements in a structure field?
>> nnz(~cellfun('isempty',{x.p})) ans = 2

8 years ago | 0

Answered
How to get the combinations of elements of two arrays?
A = [1,2,3]; B = [4,5]; [n,m] = ndgrid(B,A); out = [m(:),n(:)] "And further, if I have three or more arrays to combine, what...

8 years ago | 5

| accepted

Answered
How to access values in struct from another script?
Just return that structure when you call ArmModel inside CAL.m: m = ArmModel(); DH = m.DH;

8 years ago | 0

| accepted

Answered
create multiple submatrices from larger matrix
M = rand(5000,3); % fake data C = mat2cell(M,50*ones(100,1),3); for k = 1:50 C{k} end

8 years ago | 0

Answered
find the cell array contains a specific string
Use strfind: >> idc = strfind(file,'bore'); % search for 'bore' in all cells. >> idx = ~cellfun('isempty',idc) % logical ind...

8 years ago | 0

| accepted

Answered
Use of colours with Brewermap
I guess you are referring to my FEX submission brewermap: https://www.mathworks.com/matlabcentral/fileexchange/45208-colorbrewe...

8 years ago | 1

| accepted

Answered
Struct contents reference from a non-struct array object.
The code clearly expects the cell array groundTruth to contain a structure, which must have the fields Boundaries and String (an...

8 years ago | 0

| accepted

Load more