Answered
How to add inputdlg to my code for taking input ?
Read the inputdlg documentation: it clearly states that the output is "a cell array of character vectors containing one input pe...

7 years ago | 0

| accepted

Answered
Error using movefile: Arguments must contain a character vector.
Read the movefile help: does it say that its first input should be some image data? (hint: no). Does it say that its first input...

7 years ago | 1

| accepted

Answered
How to create a diagonal matrix from several different size matrices
It is not clear if you want those matrices to be converted to a diagonal-only matrix, or if you want a block-diagonal matrix. He...

7 years ago | 0

Answered
My function is returning ans instead of storing my sequence in a variable
"my only problem is it returns ans instead of storing the array in the variable sequence like i thought i told it do do." Just ...

7 years ago | 0

Answered
Matlab hex2dec function not converting hex into dec accurately.
Download John D'Errico's excellent base2base: >> base2base('C3B829A1E8642B78',16,10) ans = 14103068008476060536 Note that you...

7 years ago | 0

| accepted

Answered
Display the ID of the participant who has the fastest response time in Experiment 1
>> [val,idx] = min(T.Experiment1); >> T.ParticipantID(idx) ans = 507

7 years ago | 0

| accepted

Answered
Using FIND for common elements WITHOUT a loop (Vectorized?)
Use ismember and its second output argument: >> A = randperm(5) A = 3 5 4 1 2 >> B = randi(5,1,9) B = 5 1 ...

7 years ago | 0

| accepted

Answered
how to solve Unexpected MATLAB expression in the below line ?
map = [255,255,255;0,0,0;255,0,0;205,133,63;101,67,33;0,134,139]; if any(ismember(color,map,'rows'))

7 years ago | 0

| accepted

Answered
Double for loop to generate vector from sequential results
You are overthinking things, you only need one loop: vs = 1.01:0.01:1.99; s = size(vs,2); ev1 = nan(1,s); % preallocate f...

7 years ago | 0

| accepted

Answered
If I have a cell array how do I convert it into a single char
https://www.mathworks.com/help/matlab/ref/join.html

7 years ago | 1

| accepted

Answered
How to protect my functions which will be called by other programmers?
Two steps: write your function so that at the start it checks something that only you know about: e.g. your username in the abs...

7 years ago | 1

Answered
Specifying the iteration range for 'for' loops
There is no need to use a loop: >> M = randi(9,5,5) % random 5x5 matrix M = 7 1 5 6 6 7 4 8 2 5 7 ...

7 years ago | 2

| accepted

Answered
How to extract 1st digit of each number in an array
Simpler efficient numeric operations, without multiple type conversions: >> x = [12,34,56,999,430,2] x = 12 34 56 ...

7 years ago | 3

Answered
Struct variable save in parfor loop
I doubt that parfor wil work happily with dynamic fieldnames, because their order of definition is ambiguous (e.g .consider nami...

7 years ago | 0

| accepted

Answered
Finding the set of unique values for another set of unique values
>> F = @(v){unique(v,'stable').'}; >> C = accumarray(M(:,1),M(:,2),[],F); >> C{:} ans = 3 4 ans = 5 4 ans = ...

7 years ago | 1

Answered
What is the function of flag in this code?
On each loop iteration the flag value changes sign, so it follows this pattern: +1 -1 +1 -1 ... This has the effect of alt...

7 years ago | 1

| accepted

Answered
How to sort the files in a folder by date?
S = dir(...); S = S(~[S.isdir]); [~,idx] = sort([S.datenum]); S = S(idx)

7 years ago | 9

| accepted

Answered
How to sort out the matrix based on 1st column?
"How to sort out the matrix based on 1st column?" The sortrows function is stable, in the sense that the order of any two rows ...

7 years ago | 2

| accepted

Answered
Converting glcm 8*8 matrix to single row vector
Depending on the order you want, probably one of these: reshape(glcm,1,[]) reshape(glcm.',1,[])

7 years ago | 1

| accepted

Answered
How can i correct the below Matlab code
S0 = [0.1,0.2,0.3,0.4,0.5]; D0 = [2.1,2.2,2.3,2.4,2.5]; for k = 1:numel(S0) Sr = S0(k); Du = D0(k); ... the res...

7 years ago | 0

| accepted

Answered
how to creat this vector?
Exactly like in my answer to your earlier question: https://www.mathworks.com/matlabcentral/answers/442047-how-to-creat-this-ve...

7 years ago | 1

Answered
Help sending values through varargin?
The simplest solution is that whenever you call your function handle, add this at the end: fun(...,varargin{:}) For example: ...

7 years ago | 1

| accepted

Answered
Editing a cell array.
To get the actual numeric values taking into account the SI prefixes you can use my FEX submission sip2num, which can be downloa...

7 years ago | 0

Answered
Faster way of replacing multiple rows with same vector without using a loop?
Here are your two main choices for avoiding a loop. Method one: match the elements. You need to make the LHS and the RHS have t...

7 years ago | 0

| accepted

Answered
Optimization running. Error running optimization. Not enough input arguments.
According to the ga help the function should accept one input argument and return a scalar: "Write the objective function to acc...

7 years ago | 2

| accepted

Answered
how to creat this vector?
An easy solution using a loop: >> X = [1,0,0,1,1,0,1,1,1,1,0,0,0,1,1,0,1,1,1,1,1,0] X = 1 0 0 1 1 0 1 1 1 ...

7 years ago | 1

| accepted

Answered
read cell array and split into one cell array of multiple rows
name = {... 'ABCDEFGHIJKLMNOPB C D E F G ...

7 years ago | 2

| accepted

Answered
imshow command will not display my images
The reason is very simple: you forgot to use the path when you tried to read the file: D = 'C:\Users\User\Documents\MATLAB\stim...

7 years ago | 0

Answered
Undefined operator '*' for input arguments of type 'cell'
matrix.metcoef{i} = matrix.metcoef{i} .* -1 matrix.metcoef{i} = -matrix.metcoef{i}; % SIMPLER % ^ ^ ...

7 years ago | 0

| accepted

Answered
loop structure variables in formula
Rather than using loops you should learn how to use neat comma-separated lists: https://www.mathworks.com/help/matlab/matlab_pr...

7 years ago | 0

| accepted

Load more