Answered
Error using copyfile (Cannot copy or move a file or directory onto itself)
Your copyfile sytnax is incorrect. Try this: copyfile(FilenameR,Filename)

6 years ago | 1

| accepted

Answered
Reading files and writing with new extension
Use fileparts, something like this: [~,fnm] = fileparts(jpgFiles{i}); fullfile(myFolder, sprintf('%s.txt',fnm))

6 years ago | 0

| accepted

Answered
Converting .mat file with integer values to .dat causing wrong placement of the floating point
save writes text files using exponential notation. If you don't want exponential notation, don't use save In any case, using c...

6 years ago | 1

Answered
match vector with first column of matrix
Simpler with just one ismember call and some basic indexing: >> [idx,idy] = ismember(v(:),Mat(:,1)); >> res = [v(:),v(:)]; >>...

6 years ago | 2

| accepted

Answered
Matching elements in a matrix with elements in another matrix
>> [idx,idy] = ismember(A,B(:,1)); >> C = nan(size(A)); >> C(idx) = B(idy(idx),2) C = 333 112 789 112 333 762...

6 years ago | 0

| accepted

Answered
Loops slowing down dramatically with increased iterations
"...any suggestions to increase efficiency" Do not use cd to read data files, always use absolute/relative filenames. Yes reall...

6 years ago | 0

| accepted

Answered
Local functions vs. private functions
In my experience: files in a private folder are easier to maintain with version control. as each file encapsulates one function...

6 years ago | 1

| accepted

Answered
Naming figures based on the current value in a for loop
It is not possible to combine these two syntaxes into one figure call: fgh = figure(k); set(fgh, 'Name','Question 3 Part 4', '...

6 years ago | 0

Answered
Using fprintf: string in array is NaN
No need to convert data to string: >> data.x = [0;1;0;1]; >> data.y = [1;1;1;1]; >> data.z = [0;0;0;0]; >> data.name = {'Lau...

6 years ago | 0

| accepted

Answered
Unexpected behavior of mean function
"Can anyone tell me why I got this answer?" You called the command syntax of mean: https://www.mathworks.com/help/matlab/matla...

6 years ago | 1

Answered
Change for loop stepsize
This syntax does not do what you think it does: phaseerror == 0.0000000001||0.000000001||0.00000001||0.0000001||0.000001||0.000...

6 years ago | 0

Answered
Undefined function 'interp' for input arguments of type 'double'
MATLAB does not have an interp function, probably you meant to use interp1

6 years ago | 0

Answered
Replace multiple matrix in a cell array based on condition
You were almost there, just one small change is required: To assign to an unknown number of LHS elements the RHS must be scalar...

6 years ago | 1

| accepted

Answered
Find the exact multiple of a number by zero padding values.
Method One: create the output matrix first, then use indexing to add the values: R = 173; B = zeros(R,ceil(numel(A)/R)); B(1:...

6 years ago | 0

| accepted

Answered
How can I select rows in an array based on the values in the first row of another array?
idx = setdiff(1:size(yourarray,1),yourvector) out = yourarray(idx,:)

6 years ago | 1

| accepted

Answered
Search for an element in an array in reverse order
Use the 'last' option.

6 years ago | 0

| accepted

Answered
How to match Date and Data of different length?
>> D = zeros(1,numel(A)); >> [idx,idy] = ismember(A,B); >> D(idx) = C(idy(idx)) D = 4 0 0 5 0 0 9 0 7 3...

6 years ago | 0

| accepted

Answered
Matlab hexadecimal definition of a variable
>> a = sscanf('0x7C','%x') a = 124

6 years ago | 1

Answered
how do I index a vector with another vector without the use of a for loop
>> idx = ~reshape(repmat(belong,6,1),1,[]); % or use REPELEM. >> events(idx) ans = CYCLI BOXIN >> find(belong) ans = 1 ...

6 years ago | 0

Answered
My matlab doesn't work. what is the problem???
This is rather obfuscated code: par = 2*find(strncmpi('Parent', pvpairs(1 : 2 : end), 6)); What is its purpose? Why compare ev...

6 years ago | 0

Answered
Multiplication of a matrix with 6x6 cell.
Use an anonymous function instead: fun = @(m) m.*I2; S_dg = cellfun(fun,S_m,'uni',false);

6 years ago | 0

| accepted

Answered
Parsing table of string without looping
Rather than slow and complex string manipulation you can easily use sscanf to directly convert each string into a numeric matrix...

6 years ago | 0

| accepted

Answered
Does matlab have any function that can compare multiple numbers and return logical value zero or one?
>> F = @(varargin)isequal(varargin{:}); >> F(2,3,4) ans = 0 >> F(2,2,2) ans = 1 >> F(5,6,7,8,9,2) ans = 0 >> F(6,6,6,6,6,...

6 years ago | 1

| accepted

Answered
Why isn't my first line being plotted?
"Does anyone see anything that is prevent the regular plot from being plotted?" Here are two bugs on the first two lines: x=0:...

6 years ago | 0

| accepted

Answered
How to do multiple replacements in a cell array
>> [idx,idy] = ismember(cell1(:,2),cell2(:,1)); >> cell3 = cell1; >> cell3(idx,2) = cell2(idy(idx),2)

6 years ago | 0

| accepted

Answered
translating commands from python
The equivalent to numpy's where is to use indexing: https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-m...

6 years ago | 0

Answered
All possible combinations of an array and number
Download John D'Errico's excellent partitions function: https://www.mathworks.com/matlabcentral/fileexchange/12009-partitions-o...

6 years ago | 0

Answered
how to change a .txt file to a .mat file
"Anyone knows why this is the case?" dlmread only imports purely numeric data, which your file is not. You will have to parse ...

6 years ago | 2

| accepted

Answered
how to write values ​​to a vector and matrix by coordinates?
You don't need find, it is simpler and more efficient to use logical indexing: idx = A>1; x_new = x(idx); y_new = y(idx); B_...

6 years ago | 0

| accepted

Answered
error: Function definition is misplaced or improperly nested error?
"What could be the problem with it?" This: if ... ... function obj = bicomp1(c) Function definitions ca...

6 years ago | 0

| accepted

Load more