Answered
How can I write a loop that performs a function to each element in a vector?
Either use a |for| loop or <https://www.mathworks.com/help/matlab/ref/arrayfun.html |arrayfun|>: vec = [234,456,687,643,23,...

9 years ago | 1

Answered
FIND command returns empty matrix using ==
_"My problem is that I only require 1 value that best approximates where x_arr = x_rip."_ As the others have pointed out, usi...

9 years ago | 0

Answered
Index a 3D array with a 2D array of indices
You could download my FEX submission <https://www.mathworks.com/matlabcentral/fileexchange/65282-linear-indices-from-min-and-max...

9 years ago | 0

Submitted


Linear Indices From MIN and MAX
Convert MIN and MAX's output subscript indices into linear indices.

9 years ago | 0 downloads |

0.0 / 5
Thumbnail

Answered
Reference multiple elements in a cell array
This is trivial with a <https://www.mathworks.com/help/matlab/matlab_prog/comma-separated-lists.html comma-separated list>: ...

9 years ago | 0

Answered
How to find the first instance of a pattern in a cell array?
Storing lots of scalar intgers in a cell array is quite inefficient, so the first thing to do would be to store that data in a s...

9 years ago | 0

| accepted

Answered
Convert color to value
Use <https://www.mathworks.com/help/matlab/ref/rgb2ind.html |rgb2ind|>.

9 years ago | 0

Answered
How can I open a .txt file in a directory, regardless of its name??
Use |dir| to get the filename: P = 'C:\Users\Johnny\Desktop\blow_moulding_2\blow_moulding_viscoelastic\520_files\dp0\PFL-BM...

9 years ago | 0

| accepted

Answered
for loops for two variables (not nested loop)
A loop is not required. Just use |reshape|. Then you can plot them all at one too! >> N = 100; >> V = rand(1,73280); % y...

9 years ago | 0

| accepted

Answered
How to insert cell array into a workspace structure?
Did you forget to accept an answer?

9 years ago | 0

Answered
TUTORIAL: Why Variables Should Not Be Named Dynamically (eval)
PS: eval is Not Faulty: Some users apparently think that eval (and friends) must be faulty and should be removed from MATLAB al...

9 years ago | 6

Answered
Rename workspace variable (table) with a string value within a loop
Note that the data being encoded is fundamentally numeric (days and experiment number). Rather than awkwardly and pointlessly co...

9 years ago | 0

Answered
Pulling a filename from a directory given a part of the filename as a variable
ls(['*',x,'*'])

9 years ago | 0

| accepted

Answered
adding data from one cell array to a matrix
If |M| has two rows then H([1,1],:) In general H(ones(1,size(M,1)),:) or repmat(H(1,:),size(M,1),1)

9 years ago | 1

| accepted

Answered
How to insert cell array into a workspace structure?
_"However I have literally 1000's of these entry in my workspace to go through and I can not do them all individually by hand.Is...

9 years ago | 0

| accepted

Answered
Why the number of cores used in my MATLAB code calculation is dependent on the size of my matrix?
_"I don't know why the size of my matrix has to do with the multicore calculation"_ Because the overhead in preparing a small...

9 years ago | 0

Answered
Reactivate question to open new file?
This page explains how to reset that checked box: <https://www.mathworks.com/help/instrument/general-preferences-for-instrume...

9 years ago | 2

| accepted

Answered
print decimal and whole numbers as they are with right justification
>> fprintf('%10g\n',a) 0.2569 1.7856 16.2451 485.541 0.21 50

9 years ago | 0

Answered
Why do I get a complex result?
On the second iteration you generate a negative |delta| value. Then clearly the |sqrt| of a negative value is complex. You save ...

9 years ago | 1

| accepted

Answered
Saving workspace variables into one struct
Here are the two main options. First we will use this fake data: >> date = num2cell(randi(365,178,1)); >> oppt = rand(17...

9 years ago | 0

| accepted

Answered
Splitting matrix into row vectors
Simply use indexing: mat = [...]; % your matrix for k = 1:size(mat,1) vec = mat(k,:); % each row of mat .....

9 years ago | 0

Answered
How to store cell arrays
You can put cell arrays into any container variables, in particular: * cell arrays * structures Here are two cell arrays ...

9 years ago | 0

| accepted

Answered
How to access an individual column from data
If |mat| is your matrix, then something like this: mat = [...]; out = [...]; for k = 1:size(M,2) vec = mat(:,k...

9 years ago | 0

Answered
Generate a vector "b" from an already defined vector "B" several times but taking different elements of "A" each time
>> B = rand(1,4425); >> out = B(reshape(randperm(4425),15,295)); Each row of |out| is a random vector of elements of |B|...

9 years ago | 0

Answered
Combining For Loop outputs into a Matrix
>> b = 0:3; >> q = 0:10:20; >> XY = bsxfun(@plus,40+2*q(:),cosd(b)) XY = 41 40.9998476951564 ...

9 years ago | 1

Answered
How to get Matlab to print both values and variable name
Your approach is fundamentally flawed because you are storing meta-data in the variable names: trying to access that meta-data w...

9 years ago | 2

| accepted

Answered
How to operate on specific diagonal elements of a matrix?
You need to use <https://www.mathworks.com/help/matlab/ref/sub2ind.html |sub2ind|>: >> idx = sub2ind(size(k),u,u); >> k(...

9 years ago | 0

| accepted

Answered
Using regexp to match multiple substrings, two questions
You do not need to use |regexp| to fulfill the given requirements: >> st1 = 'This string is going to be searched'; >> fu...

9 years ago | 0

| accepted

Answered
How to determine the size of an array of functions??
There is no general solution because the size of the output can depend on the inputs. Consider: >> fun = @(x)x+2; >> fun...

9 years ago | 1

| accepted

Answered
Using index vector to rearrange order of variables
Where |idx| is the index: C{1} = C{1}(idx); C{2} = C{2}(idx);

9 years ago | 0

Load more