Answered
String of text as function output
Put the outputs into cell arrays: N = 10; A = cell(1,N); B = cell(1,N); C = cell(1,N); D = cell(1,N); for k = 1:N ...

10 years ago | 0

| accepted

Answered
How to use placeholder in a loop?
You could use <https://www.mathworks.com/help/matlab/ref/struct.html structure> fields: >> S.data1 = 123; >> S.data2 = 4:6...

10 years ago | 0

Answered
How can i seperate numbers from strings while using textscan?
>> str = '2000,146.557,OE,-300,150 2000,146.625,FOB,0,0'; >> textscan(str,'%f%f%s%f%s%f%s%f%f','Delimiter',',') ans = ...

10 years ago | 0

| accepted

Answered
how do I save variables in one function so as they can be used in other functions? so they can be used
How to pass arguments is covered quite clearly in the introductory tutorials. All beginners should do these tutorials. They intr...

10 years ago | 1

| accepted

Answered
Repeating elements (vector)
There are most likely much more efficient algorithms than this: >> N = 4; >> X = (1:N)'*ones(1,N); >> X(triu(true(N))...

10 years ago | 2

| accepted

Answered
Sorting files inside a folder
This code gives the order requested in the original question: C = {... '1 1a.bmp';... '1 1b.bmp';... '1 2a.bmp'...

10 years ago | 1

| accepted

Answered
Extracting numbers from a text file
More efficient and more robust than using |regexp| would be to simply use one of the <https://www.mathworks.com/help/matlab/data...

10 years ago | 0

Answered
switch case - choose from array
Do the conversion before the loop: C = num2cell(optionsVec); for ... switch ... case C ... end end

10 years ago | 1

| accepted

Answered
How to find a unique point of a set of data
If the data is reasonably smooth, then fitting a <https://www.mathworks.com/help/matlab/ref/spline.html |spline|> may be a suita...

10 years ago | 1

Answered
Call a figure to show just like a variable
Use the figure handle: fgh = figure(...) Using the handle you can |set| and |get| and properties of the figure (such as |...

10 years ago | 0

| accepted

Answered
Distance between two points on the sphere.
I guess you want to find the shortest distance _along the surface of the sphere_, not just the euclidean distance between the po...

10 years ago | 2

| accepted

Answered
How can I automatically scale each of the elements of a Vector V to the respective size of the cell of the struct S?
You can use <https://www.mathworks.com/help/matlab/ref/arrayfun.html |arrayfun|> to do this quite neatly: >> vec = [1,9,4,0...

10 years ago | 0

Answered
How to change preferences for edit command
After |edit| or |CRTL+D| you click "yes" instead of "no": <</matlabcentral/answers/uploaded_files/67503/Capture.PNG>> If a...

10 years ago | 2

| accepted

Answered
How can I hide a part of my function?
NaN values are not plotted, so you can simply replace any values that you do not want to see with NaN: x=(0:0.01:70).'; ...

10 years ago | 2

| accepted

Answered
Store all iteration loop outputs in a file
If the file is very large then you could use <http://www.mathworks.com/help/matlab/ref/memmapfile.html |memmapfile|>: <https:...

10 years ago | 0

| accepted

Answered
logical indexing 3d array with 2d array
Exactly like I showed you in <https://www.mathworks.com/matlabcentral/answers/320694-how-to-index-3d-array-with-2d-array your ea...

10 years ago | 0

| accepted

Answered
Why fprintf('%3.1f',round(-eps)) prints -0.0?
You are missing the fact that MATLAB has two zeros: positive zero and negative zero, which have different HEX values. This is a ...

10 years ago | 2

| accepted

Answered
Finding location of a variable in a folder of .m files.
Use MATLAB. It has a tool that lets you search for text inside files: <https://www.mathworks.com/help/matlab/matlab_env/findi...

10 years ago | 0

| accepted

Answered
Obtaining data from matrix outside multiple ranges
Use the <https://www.mathworks.com/help/matlab/ref/or.html |or|> operator |||: A = [1 -2 3 4 5 6 7; 3 4 5 6 7 8 9;...

10 years ago | 0

| accepted

Answered
How to merge cell (100 x 3) of arrays into a single cell (100 x 1) by concatenating the arrays ?
Where |X| is the input cell array of size N*3: cellfun(@(a,b,c)horzcat(a,b,c),X(:,1),X(:,2),X(:,3),'UniformOutput',false)

10 years ago | 1

| accepted

Answered
what does an handle for imshow mean
According to the <https://www.mathworks.com/help/images/ref/imshow.html |imshow|> documentation this syntax: himage = imshow...

10 years ago | 0

Answered
how to index 3D array with 2D array ?
*Method one* create a new image: image_b = bsxfun(@times,double(map),image_a) or on newer MATLAB versions with implicit a...

10 years ago | 2

| accepted

Answered
How to operate on comma separated lists ?
Introduction: Comma-separated lists are really very simple. You use them all the time. Here is one: a,b,c,d That is a comma-se...

10 years ago | 10

| accepted

Answered
Compare two numeric cell arrays
Once I got rid of that unnecessary conversion to numeric value then this task becomes a lot easier. I also <https://www.mathwork...

10 years ago | 1

| accepted

Answered
Is there a way to extract a specific element adjacent to an element that you specify in a matrix and change it. So I would like to extract 0 adjacent to 153 in this matrix. | 0 0 0 0 | | 0 153 0 0 | | 0 0 0 0 |
A simple application of <https://www.mathworks.com/help/matlab/ref/conv2.html |conv2|> lets us efficiently identify the indices ...

10 years ago | 2

Answered
How to find arrays in a cell array
Faster and simpler than using a function handle: idx = cellfun('size',c,1)<5; c(~idx)

10 years ago | 0

Answered
How can I merge 3 matrices into one and skip some variables?
Doing this in a loop is very inefficient. You should do this all at once using indexing: idx = [1:47,60:107,131:178]; out ...

10 years ago | 1

| accepted

Answered
Replacing numbers in a matrix
MyArray(400) = 0.3; MyArray(900) = 0.9;

10 years ago | 0

Answered
Why do I get "Subscript indices must either be real positive integers or logicals."??
Because of this line: i=0:178 You start your indices from zero, but MATLAB indices start from one. Read the error message...

10 years ago | 0

| accepted

Answered
Finding values of a variable as parameters change
You need to learn about <https://www.mathworks.com/help/matlab/function-handles.html function handles>, and how to define them: ...

10 years ago | 0

| accepted

Load more