Answered
How to call function using list element?
Use str2func, e.g.: function test() C = {'sub1','sub2'}; F = cellfun(@str2func,C,'uni',0); for k = 1:numel(F) F{k}() e...

7 years ago | 2

| accepted

Answered
while loop for series
"what am i doing wrong?" You are not actually adding anything to y on each iteration, instead you completely overwrite y with a...

7 years ago | 0

Answered
Error reading .mat file
MIPAV wrote a dud file. Open that file in any reliable text editor, and you will find that it contains the text "MIPAV is writi...

7 years ago | 0

| accepted

Answered
Matrix as an input argument, multiple outputs
Your indexing assumes that the input matrix has size 2x2. The assignment does not state that restriction, so you should write y...

7 years ago | 0

Answered
problem in writing files
The problem is likely caused by the fact that your images are actually written to a different directory than you think. I stron...

7 years ago | 0

| accepted

Answered
Combining several asymmetric matrices to fit each other
Do this for each pair of matrices A and B: >> A = [-2,6,2,7,1;4,-5,2,3,NaN;6,1,3,NaN,NaN;2,2,NaN,NaN,NaN;4,NaN,NaN,NaN,NaN] A ...

7 years ago | 1

| accepted

Answered
split matrix in diffrent sizes matrixes according to indicies vector
Do NOT create numbered variables. Indexing is simpler and much more efficient. You can use mat2cell to split the matrix up into...

7 years ago | 1

| accepted

Answered
Selecting values from a .txt file which are prefaced by a phrase
You could use textscan to import that file data quite efficiently: opt = {'Delimiter',' =','MultipleDelimsAsOne',true,'CollectO...

7 years ago | 1

Answered
putting the combinations of a sequence in an cell array
>> vec = 1:5; >> fun = @(n)num2cell(combnk(vec,n),2); >> out = arrayfun(fun,1:numel(vec),'uniformoutput',0); >> out = vertcat...

7 years ago | 1

| accepted

Answered
Find the number of a row in a matrix that have a minimum value compare to another specific row
>> A = [0,28;28,0;9,26;29,21;10,32;3,26] A = 0 28 28 0 9 26 29 21 10 32 3 26 >> vec = ...

7 years ago | 1

| accepted

Answered
String to serial date number
datenum(fdate, "yyyy-mm") % ^ this character does not match your date data!

7 years ago | 0

| accepted

Answered
Selecting specific values from anonymous functions
You could call subsref directly, e.g.: subsref(TsMat(thetas),substruct('()',{3,':'})) and similarly for the other function cal...

7 years ago | 2

| accepted

Answered
Create a matrix from some given matrices
>> p = 2; >> N = 3; >> A = randi(9,p,p) A = 6 7 2 1 >> B = randi(9,p,p) B = 3 1 1 8...

7 years ago | 0

Answered
How do I vectorize adding array elements based on indices?
Using accumarray: >> potential = [1,2,3,4,5]; >> train = [8,7,8,7,8,7,8,7]; >> destination = [1,1,1,2,2,2,3,4]; >> poten...

7 years ago | 0

| accepted

Answered
packing function for the file exchange
The problem is a bit obscure, but it is caused by the fact that you have HTML documentation with the same name as your main func...

7 years ago | 1

| accepted

Answered
Scatter works but Plot gives error
You cannot just swap functions around and expect them to work: they have different calling syntaxes, so you need to call plot wi...

7 years ago | 0

Answered
How can I repeat same process for different matrices?
Of course there is an easy way: just use Indexing! Indexing is simple and very efficient: C = {boston,paris,beijing,...}; for ...

7 years ago | 0

| accepted

Answered
Saving the content of a cell array in different matrices automatically
I just skimmed through the BRAPH toolbox documentation from this website: http://braph.org/manual/introduction/ There is nothi...

7 years ago | 0

Answered
Not enough input arguments
integral(@f,-1,4) % ^^ the first input needs to be a function handle! https://www.mathworks.com/help/matlab/function-ha...

7 years ago | 0

| accepted

Answered
Create array address using for loop
Just use cell arrays: N = 5000; A = cell(1,N); B = cell(1,N); C = cell(1,N); for k = 1:N [A{k},B{k},C{k}] = imread('ff...

7 years ago | 0

| accepted

Answered
Fill gaps using Nan in for loop
Using two accumarray calls: >> data = [0,50;1,100;2,200;3,300;5,500;6,600;7,700;10,1000;0,30;2,20;6,40] data = 0 50...

7 years ago | 0

| accepted

Answered
could anyone help me how to display all the numbers inaddition to the numbers present.
>> A = [1,2;1,3;2,5;2,4;3,5;4,6;4,5] A = 1 2 1 3 2 5 2 4 3 5 4 6 ...

7 years ago | 0

| accepted

Answered
How can I find a row in a matrix in which all elements apply to a relational operator?
>> idx = all(A>0.25,2) % logical index idx = 0 0 0 1 0 0 >> find(idx) % subscript index a...

7 years ago | 0

| accepted

Answered
str2num not working on array
It would be simpler to use a structure (in this example I entered "Red" into the dialog box): >> S.red = [1,0,0]; >> S.green...

7 years ago | 0

Answered
Using strfind to find character index in word
>> HangWord = 'each'; >> Guess1 = 'e'; >> index = strfind(HangWord, Guess1) index = 1

7 years ago | 0

Answered
Variable in Text [Matlab]
You can use dynamic fieldnames: https://www.mathworks.com/help/matlab/matlab_prog/generate-field-names-from-variables.html Alt...

7 years ago | 1

| accepted

Answered
Error using accumarray First input SUBS must contain positive integer subscripts.
"I have already read all questions and answers about it here, cant figure out whats wrong." After reading many answers, you sho...

7 years ago | 0

Answered
Find cells that start with text and combine it with next cell
>> C = {'Test1';'10v';'20va';'30v';'50v';'65v';'Test2';'80v';'100v'} C = 'Test1' '10v' '20va' '30v' '...

7 years ago | 1

| accepted

Answered
Move selected column from a matrix to another
Replace the loop with this: idx = M(310,:)>=Xmin & M(310,:)<=Xmax & M(620,:)>=Ymin & M(620,:)<=Ymax; x(:,idx) = M(:,idx); Not...

7 years ago | 0

| accepted

Answered
Create variable from an excel entry
This should get you started (note that I named the variable out rather than Plot, as it is bad practice to use names which only ...

7 years ago | 0

Load more