Answered
Find the intersect of two columns from different matrix but keep the corresponding cells from the same row along with the intercept values
>> A = [2,4,6,8,10;2,3,5,3,2] A = 2 4 6 8 10 2 3 5 3 2 >> B = [2,3,5,8,10;1,2,2,2,1] B = ...

7 years ago | 0

| accepted

Answered
Alternation without for loop
>> N = min(numel(A),numel(B)); >> V = [reshape([A(1:N);B(1:N)],1,[]),A(N+1:end),B(N+1:end)] V = 1 0.5 2 0.2 3 0.4 4 ...

7 years ago | 1

Answered
Modify a cell array and obtain a new cell array
The problen is that you try to access a row of GGG which does not exist. You define GGG as a 1x2 cell array: GGG= {[...],[...]...

7 years ago | 0

| accepted

Answered
Matching closest values to each other
>> [~,idx] = min(abs(bsxfun(@minus,B,A.')),[],2); >> C = [B,A(idx)] C = 39.167 39.342 39.892 39.942 40.592 4...

7 years ago | 0

Answered
finding location of logical 1 row wise by column
[idr,~] = find(yourMatrix)

7 years ago | 0

| accepted

Answered
Difference between ' (single quote) vs " (double quote)?
https://www.mathworks.com/help/matlab/characters-and-strings.html In a nutshell: single quotes define a character vector with ...

7 years ago | 9

| accepted

Answered
Array vs. Matrix Operations
What "compatible sizes" means is explained on this page: https://www.mathworks.com/help/matlab/matlab_prog/compatible-array-siz...

7 years ago | 0

| accepted

Answered
SAVE command: How to specify the variable to be saved if it is a variable inside an array. assignin has been used to create the variable from a string in an array.
save using the structure syntax: S = struct('theNameYouWant',x); save(...,'-struct','S')

7 years ago | 0

| accepted

Answered
How to fill NaN values in 3d array using interpolation?
The simple solution is to download this: https://www.mathworks.com/matlabcentral/fileexchange/4551-inpaint_nans

7 years ago | 1

| accepted

Answered
how to extract and load images and data from multiple .mat files present in a folder
https://www.mathworks.com/help/matlab/import_export/process-a-sequence-of-files.html D = 'path to the folder where the files ar...

7 years ago | 1

Answered
creating matrix from a vector
>> v = [0,0,4,6] v = 0 0 4 6 >> n = ceil(v/2); >> w = 1:max(n); >> m = bsxfun(@times,v,bsxfun(@le,w(:),n)) m = ...

7 years ago | 1

| accepted

Answered
How can I create an input row only excisting randomly only out of -1 and +1?
>> V = [-1,1]; >> X = randi(2,1,23); >> V(X) ans = -1 -1 1 1 1 -1 -1 -1 1 -1 1 -1 1 1 1 -1 1 1 ...

7 years ago | 1

Answered
How to extract a value from mat file
S = load(...) S.Fs

7 years ago | 0

Answered
Calling Matrix that is indexed, in a for loop
The easiest approach is to use a cell array: T{1} = [1,2]; T{2} = [2,3,4]; T{3} = [3,4,5]; T{4} = [3,4,5]; T{5} = [1,5]; f...

7 years ago | 0

| accepted

Answered
Question about import a .txt file into matlab
Your code has several issues, the most significant ones are: you incorrectly used the optional third input, apparently to try a...

7 years ago | 1

| accepted

Answered
Index for subfolders without *.pdf files
Simpler and more robust: D = 'path to the main folder'; S = dir(fullfile(D,'*')); N = setdiff({S([S.isdir]).name},{'.','..'}...

7 years ago | 2

| accepted

Answered
removing NaN values from mat file
load into an output variable (which is a scalar structure), then loop over the fields: https://www.mathworks.com/help/matlab/re...

7 years ago | 2

| accepted

Answered
fprintf matrix question. Need help.
No loop is required: >> x = 1:8; >> y = exp(x); >> fprintf('The force in link (%d)= %g N\n',[x;y]) The force in link (1)= 2....

7 years ago | 0

| accepted

Answered
Weird reading data: seed
The problem is data.seed. When you concatenate that numeric value onto character vectors MATLAB does not implcitly convert the ...

7 years ago | 0

Answered
Changing the For LOOP conditions
If val has a value either 1 or 2: for k = 1:val:n If val is a boolean (i.e. 0 or 1) then simply do either of these: for k = 1...

7 years ago | 0

Answered
What should I use instead of cd?
Your fullfile usage (which you commented out) does not make much sense, in particular: concatenating everything together before...

7 years ago | 0

Answered
Extract files of specific extension from already searched folder
>> S = dir('*.*'); >> S.name ans = . ans = .. ans = archive ans = iregexp.m ans = iregexp.png ans = iregexp.zip ans = ir...

7 years ago | 1

| accepted

Answered
Derivative of cell with matrices
fun = @(m)diff(m,1,2); out = cellfun(fun,X,'uni',0);

7 years ago | 0

| accepted

Answered
Is there a way to select a good color scheme for easy figure viewing
Do NOT use jet ! Read these to know why: https://blogs.mathworks.com/steve/2014/10/20/a-new-colormap-for-matlab-part-2-troubles...

7 years ago | 1

| accepted

Answered
Create a matrix from two matrices
>> GG = [S,[G(1,:);S(2,end)+cumsum(diff([0,G(2,:)]))]] GG = 1 2 1 2 1 3 4 1 2 2 3 4 5 ...

7 years ago | 0

| accepted

Answered
Optimization with loops Error in optim.problemdef.OptimizationProblem/solve
I don't see a simple vectorized solution, but one for loop will be quite efficient: A = [1;3;5;7] B = [10;12;14;19] C = nan(s...

7 years ago | 1

Answered
Need help fixing Vercat error
This line will cause an error: % ' '... If you want to continue to the next line then you need to use an...

7 years ago | 0

| accepted

Answered
Problem using the matlab function randsample
MATLAB is trying to access the wrong randi function. This might occur if you created your own randi function, or a third-party ...

7 years ago | 0

| accepted

Answered
variable format issue using copyfile
Your main bug is on this line: copyfile('finalImg1', 'destDir1'); Your code looks for files literally called 'finalImg1', whic...

7 years ago | 1

| accepted

Answered
How to save every answers in matrix with 2 for loops.
You don't need loops, with the correct indices and one simple addition: >> [X,Y] = ndgrid(1:4); >> d1(X(:),:) + d2(Y(:),:) an...

7 years ago | 0

| accepted

Load more