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...

7 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...

7 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...

7 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 =...

7 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...

7 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...

7 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...

7 years ago | 0

| accepted

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

7 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 = ... ... ...

7 years ago | 0

| accepted

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

7 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...

7 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;

7 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

7 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...

7 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...

7 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...

7 years ago | 0

| accepted

Answered
Making one structure out of two structures
A general solution for two identically-sized structures, with any number of fields: >> F.A = 'apple'; >> F.B = 'ball'; >> E.C...

7 years ago | 2

| accepted

Answered
Why are values in my loop filled with NaN?
Actually this has nothing to do with division by zero. When you read the NaN help it lists several ways that NaNs can occur: "T...

7 years ago | 1

| accepted

Answered
I wonder the way of reading data for some specific order.
>> sort([1:4:34,2:4:34]) ans = 1 2 5 6 9 10 13 14 17 18 21 22 25 26 29 30 33 34

7 years ago | 1

| accepted

Answered
Sort one Vector according to other Vector in octave
If you use a character array and want to sort its rows, then you need to use the indexing on its rows: Year_Month_Name = Year_M...

7 years ago | 0

| accepted

Answered
How do a get a specific day of the year?
The problem is caused by this line: [year month day] = ymd(date); When you have variables named year, month, and day, then you...

7 years ago | 2

| accepted

Answered
storing char from a cell to a varaible
c = c{1}(1) https://www.mathworks.com/help/matlab/matlab_prog/access-data-in-a-cell-array.html

7 years ago | 0

Answered
1D series to 2D stacked
In one line: B = A>=(10000:-1:1).' Or for versions prior to R2016b: B = bsxfun(@ge,A,(10000:-1:1).');

7 years ago | 1

| accepted

Answered
How to change file name and convert the file
S = dir('*.jpg'); for k = 1:numel(S) im = imread(S(k).name); im = imresize(im,[256,256]); im = rgb2gray(im); ...

7 years ago | 1

| accepted

Answered
How to change a value in an array when a condition is met?
idx = Velocity(:,3)==0; vec = [1;-1]; Velocity(idx,4) = vec(randi(numel(vec),nnz(idx),1))

7 years ago | 0

| accepted

Answered
How to create an array that counts the number of consecutive repeating numbers in a given array?
>> A = [1;1;1;2;2;2;2;2;3;3;4;4;4;4;4;4;4;5;5;5;5;1;1;1;3;3;3;3;3;3]; >> V = diff(find([1;diff(A)~=0;1])); >> C = arrayfun(@(n...

7 years ago | 0

| accepted

Answered
Splitting an array every n rows
"so ideally M would be:" M{1,:} = Accel(1:80,:) M{2,:} = Accel(81:160,:) etc etc Just use mat2cell: >> N = 80; >> A = ...

7 years ago | 0

| accepted

Answered
Mapping values of two different-length vectors to index-vector
>> [~,X] = histc(a,b) X = 1 1 2 3 3 4 5 6

7 years ago | 1

| accepted

Answered
how to remove rows if only the first row contains a specified value
One Value: the simple MATLAB way, either keeping the other rows: >> X = D(:,1)~=281; >> D = D(X,:) D = 279 6 6 ...

7 years ago | 2

| accepted

Load more