Answered
How to fix " Index exceeds matrix dimension" error?
You define the variable |neighboring_anchor_n| on line 21, with this: neighboring_anchor_n=length(neighboring_anchor_index)...

8 years ago | 1

| accepted

Answered
"Locale" issue. Danish created-date extracted from file
Avoid the whole problem by using the structure's |datenum| field, which is a MATLAB <https://www.mathworks.com/help/matlab/ref/d...

8 years ago | 2

| accepted

Answered
Hello, I am trying the plot this but I keep getting same error. Could you please help me?
All of |XX|, |YY|, and |ZZ| have size 1x2. 1x2 is a vector. It does not make much sense to plot the surface of a vector, which i...

8 years ago | 0

Answered
Selecting Value in matrix already indexed
Some options: 1. avoid the situation by defining a function in an Mfile. This is the simplest and probably most efficient sol...

8 years ago | 1

| accepted

Answered
Cannot pre-allocate an empty matrix?
There are many ways: # tell the editor to ignore the warning: right click, "suppress ... on this line" # use a preallocated ...

8 years ago | 0

| accepted

Answered
Convert 6381x3 double to 1x3x6381 double?
You can use <https://www.mathworks.com/help/matlab/ref/permute.html |permute|>: permute(arr,[3,2,1]) Depending on the or...

8 years ago | 2

| accepted

Answered
How can I make matlab import a specific .xml file, instead of having to use having to use the same filename for different files?
Apparently you are using this third-party tool: <https://github.com/fiji/TrackMate/blob/master/scripts/importTrackMateTracks....

8 years ago | 0

| accepted

Answered
Run a script on all files in a folder
You need to include the required directory path whenever you do anything with files that are not in the current directory, it is...

8 years ago | 1

Answered
why i getting this error Error using <= Not enough input arguments.
_"why i getting this error Error using <= Not enough input arguments."_ Because the function <https://www.mathworks.com/help/...

8 years ago | 0

Answered
I have n*n matrix.I want to get all the elements of 1st column of nth rows like A(:,1). Now how will i arrange all the n elements into a single row i,e b=[A(1,1) A(2,1) A(3,1)............ A(n,1)].What will be the command for n being large say 5000?
The most general, correct answer is to use <https://www.mathworks.com/help/matlab/ref/transpose.html |transpose *.'*|> (rather t...

8 years ago | 1

| accepted

Answered
How do I define an anonymous function with a function as an argument?
Assuming that |y0|, |h|, and |f| are defined in the local workspace: E = @(z) setEpsilon3(y0,h,f,z); What were you tryin...

8 years ago | 0

| accepted

Answered
random sorting issue with randperm function
I suspect that you actually want to use the same sort indices for all three vectors: idx = randperm(numel(x1)); x1_rand ...

8 years ago | 0

Answered
How can i save and access data in a mat file.
_"i would also like your suggestions on how to name the variables..."_ *Don't name variables like that!* Creating or accessin...

8 years ago | 1

| accepted

Answered
Add data of a matrix based on an other matrix
Loops are not required. One easy way would be to use <https://www.mathworks.com/help/matlab/ref/accumarray.html |accumarray|>: ...

8 years ago | 0

| accepted

Answered
Vector isn't storing the values passed to it?
pmt = 'Enter a positive number: '; num = str2double(input(pmt,'s')); vec = []; while num>0 vec = [vec,num]; ...

8 years ago | 0

| accepted

Answered
Subtracting vector elements, with an if condition?
a = [1 2 3 4 5 6 7 7 7 7 7 8 9 10 11 12 13]; b = a; d = diff(a)==0; b([false,d] | [d,false]) = 0

8 years ago | 0

| accepted

Answered
convert list of strings to char arrays
One at a time: <https://www.mathworks.com/help/matlab/ref/char.html |char|> Or all at once: <https://www.mathworks.com/help/m...

8 years ago | 1

| accepted

Answered
merge 2 tables both have the same variable name
vertcat(A,B) From the <https://www.mathworks.com/help/matlab/ref/vertcat.html |vertcat|> help: _"If the inputs are tables, ...

8 years ago | 2

| accepted

Answered
For loop within a function f
The answer to your question is already in the title to your question: _"For loop within a function f"_ The attmempts that you sh...

8 years ago | 0

Answered
%How can i create this vector? Please I need your help.
Simple use of |repelem| and basic MATLAB indexing: V = repelem(1:50,7); V(6:7:end) = 0; V(7:7:end) = 0; Or for old...

8 years ago | 1

Answered
how to extract subarray of cell array based on logical condition?
Actually all you need is <https://www.mathworks.com/help/matlab/ref/strcmp.html |strcmp|>. Given: C = {... 'TS-G5-box11-...

8 years ago | 0

Answered
why do strings I define to same length have different lengths?
This happens because the font that you are using to display those strings is not a fixed-width font (i.e. is not <https://en.wik...

8 years ago | 1

| accepted

Answered
csvread has problems reading all columns
This will read your non-standard CSV file (attached to this answer) into matrix |M|: fmt = repmat('%f',1,98); % two extra c...

8 years ago | 0

| accepted

Answered
Find continuous file name jump
C = { % fake data: 'SHARK_225054651_41_0548_r001' 'SHARK_225054651_41_0548_r005' 'SHARK_225054651_41_0548_r009' 'S...

8 years ago | 2

| accepted

Answered
I am writing a function that reads different input data files, one of them is a mat file and when i read it then store it in an output mat file, its not showing the values of the fields. rather its just showing that is a 1X1 array
The output of <https://www.mathworks.com/help/matlab/ref/load.html |load|> is a struct, so you can use the |'-struct'| option wi...

8 years ago | 0

Answered
how to execute str2num or str2double in matlab?
Simple, and possibly the most efficient way: >> t = {'2','u1','u2 '}; >> sscanf([t{:}],'%du') ans = 2 1 ...

8 years ago | 0

| accepted

Answered
How do I vectorize each digit of an integer and store it as an array?
>> num2str(100)-'0' ans = 1 0 0 If you want all digits, regardless of position and role (e.g. exponent): ...

8 years ago | 4

| accepted

Answered
Adding structs within structs in a larger scale (without having to manually specify every field name)
I don't really follow your code at all, but it seems to me that you would be better off using one simple <https://www.mathworks....

8 years ago | 0

| accepted

Answered
value of for loop increases without even executing all the lines inside the loop
You call some scripts, e.g. |bisection|, which redefine |i|. This is a classic example of why using functions is much better ...

8 years ago | 0

| accepted

Answered
Error using cd Cannot CD to ...(Name is nonexistent or not a directory).
Get rid of the |cd| entirely: D = '/LENOVO/Neolab/P5_260418/10sIllumination'; S = dir(fullfile(D,'*.swt')); N = numel...

8 years ago | 0

Load more