Answered
Reading a csv file with " " separators
opt = {'Delimiter',',"', 'MultipleDelimsAsOne',true, 'HeaderLines',3}; [fid,msg] = fopen('test.csv','rt'); assert(fid>=3...

9 years ago | 2

Answered
How to create multiple text files in a for loop?
You have too many loops. Try this: A = [1,2,3]; B = [4,5,6]; C = {A,B}; for k = 1:numel(C) [fid,msg] = fopen(...

9 years ago | 0

Answered
Is there any other way than manually updating the noise parameter such that the algorithm re runs for every parameter and then plots the graph ?
Use a loop: vec = 0.01:0.01:0.10; % or whatever step size you need. out = nan(size(vec)); for k = 1:numel(vec) ...

9 years ago | 0

| accepted

Answered
find the position of en element if you have the increment
You need to compare the difference against a (carefully selected) tolerance: >> z = 0:-0.1:-16; % do not use square bracket...

9 years ago | 0

| accepted

Answered
Converting a 2D Array into a 3D Array
Perhaps: reshape(M,[1062,100,3]) or permute(reshape(M,[1062,3,100]),[1,3,2])

9 years ago | 0

Answered
Nested structure array assignment
One option would be to use <https://www.mathworks.com/help/matlab/ref/setfield.html |setfield|>: >> S = struct(); >> S =...

9 years ago | 1

Answered
Can somebody help me in removing 10 rows above and below, if the difference between two rows in first column is >2
Using exactly the code that I gave in <https://www.mathworks.com/matlabcentral/answers/372007-i-want-to-remove-2-rows-above-and-...

9 years ago | 0

Answered
How the remove single apostrophe from a string?
_"how to remove the apostrophe so that I can use the equation..."_ You can't, because a char array does not really have singl...

9 years ago | 2

| accepted

Answered
How to find the minimum length of a cell array
Simpler and faster: min(cellfun('size',M,2))

9 years ago | 2

Answered
How to edit field values in a .mat file?
Either: * |load| the fields/variables, change the values, then |save| them again, or * Use <https://www.mathworks.com/help/m...

9 years ago | 0

Answered
Hi! Could somebody tell me why few days ago this code worked and now I tried it again and gives me this error? Thank you!
Replace the |fopen| line with this: [fid,msg] = fopen('sp3data.txt'); assert(fid>=3,msg) And then read the displayed ...

9 years ago | 0

Answered
How to make it in for loop
cell2mat(y)

9 years ago | 0

| accepted

Answered
I want to remove 2 rows above and below, when the difference between two rows in first column is more than 2. For example: if have an array a=[0 2 2; 2 5 3; 4 2 6; 10 6 7; 12 5 9; 14 2 7; 15 5 6] and i want a new array a=[0 2 2;15 5 6]
>> x = [true;diff(a(:,1))<=2]; >> idy = [true;true;x(1:end-2)]&[true;x(1:end-1)]&x&[x(2:end);true]&[x(3:end);true;true] ...

9 years ago | 1

| accepted

Answered
How can I use 'while' ??
_"What is wrong with this?"_ Too many variables. Beginners sometimes want to store their data in lots of separate variables, ...

9 years ago | 0

| accepted

Answered
How to acces multiple fields of a structure at the same time?
>> fun = @(S,varargin) cellfun(@(f)S.(f),varargin); >> fun(test,'a','c') ans = 3 7

9 years ago | 3

Answered
How to store the output of a for loop in a matrix?
Why waste time writing an loop as if MATLAB is an ugly low-level language like C++? Using logical indexing is simpler and very e...

9 years ago | 0

| accepted

Answered
How to read a variable from matfile by searching for its name?
You can use <https://www.mathworks.com/help/matlab/ref/whos.html |whos|> to get a list of the variables in a |.mat| file.

9 years ago | 0

Answered
creating loop with two variables
Why waste time writing an ugly loop? Here is a simpler solution in just two lines: >> a = 0:2:10; >> b = 0:2:6; >> v ...

9 years ago | 2

Answered
How to check if variable is in workspace?
Based on my comment to your question: a much better approach is to use <https://www.mathworks.com/help/matlab/ref/persistent.htm...

9 years ago | 0

| accepted

Answered
finding the average value
bsxfun(@rdivide,sum(A,1),B) ans = 2.8 1.6 1.2 1

9 years ago | 0

| accepted

Answered
How to find the position of NaN values simultaneously in more arrays?
Just like in every other instance when beginners store data in lots of individual variables, processing that data is much simple...

9 years ago | 2

Answered
Colormap won't change
You are plotting lines using <https://www.mathworks.com/help/matlab/ref/plot.html |plot|>, which determines the line color using...

9 years ago | 1

| accepted

Answered
Upper first letter of a text input
Simpler: [upper(newuser.name(1)),newuser.name(2:min(30,end))]

9 years ago | 4

Answered
Counting runs in a vector
>> V = [0,0,1,2,3,2,2,1,2,2,1,2,3,4,3]; >> W = V([true,0~=diff(V)]); % remove repeats >> diff(W([true,0~=diff(sign(diff(...

9 years ago | 1

| accepted

Answered
insert ones at given position of matrix
Use <https://www.mathworks.com/help/matlab/ref/sub2ind.html |sub2ind|>: >> rd = zeros(4,6); >> x = [3,1,3,1,1,1]; >> ...

9 years ago | 0

| accepted

Answered
Attempt to reference field of non-structure array.
<https://www.mathworks.com/help/images/ref/dicomread.html |dicomread|> returns a numeric array. So what do you expect |ct3d.D| t...

9 years ago | 0

Answered
How to use findpeaks for every column of a matrix and store the result in a cell array?
*Preallocate* it as a cell array: peak_1q = cell(1,numel(locs1)); If you do not preallocate then apparently you have som...

9 years ago | 0

| accepted

Answered
How can I get my fucntion to accept doubles.
This makes no sense: f(x) = ... because you are trying to do is use |x| as an index, which clearly makes no sense for no...

9 years ago | 0

| accepted

Answered
Load data and create loop
The problem is caused by incorrect usage of <https://www.mathworks.com/help/matlab/matlab_prog/command-vs-function-syntax.html c...

9 years ago | 0

Answered
Replace part of string with variable
str = sprintf('designPoint1.SetParameterExpression(parameter1, "%d")',dia); execwbcommand(str)

9 years ago | 2

| accepted

Load more