Answered
Undefined function 'power' for input arguments of type 'function_handle'
That second @(...) makes no sense, so remove it: m_w2(i,j) = fzero(@(m_w2)fzerotry(m_w2, cv_249(i), cv_251(j)), 4)

9 years ago | 0

Answered
Use linspace without scalar input?
An efficient general solution for any size |y| using <https://www.mathworks.com/help/matlab/ref/linspace.html |linspace|> and <h...

9 years ago | 0

Answered
Count sequence of zeros with For loop
Simply use |diff| and then run over the columns: a = [... 3 0 7 8 0 0 1 5 1 0 5 0 0 2 3 0 0 2 0 0 1 4 7 0...

9 years ago | 0

Answered
Reading of a complex file into a matrix
Something like this perhaps: opt = {'HeaderLines',2, 'MultipleDelimsAsOne',true}; fmt = ['%f%3c%2c',repmat('%f',1,7)]; ...

9 years ago | 0

| accepted

Answered
Nested structure error with definition . please help.
You cannot run your function by clicking the big green RUN button. Putting that button on the ribbon was the worst design decisi...

9 years ago | 0

| accepted

Answered
Convert three array into one matrix.
Use <https://www.mathworks.com/help/matlab/ref/meshgrid.html |meshgrid|>: >> A = 1:3; >> B = 4:7; >> Z = 8; >> [Am...

9 years ago | 2

| accepted

Answered
How to extract the most similar(closest) one
To obtain the closest row without requiring a tolerance value: M = [1.0,2.2,3.1,4.0;1.1,3.3,4.7,6.2;2.2,4.9,5.3,6.2;1.1,2.3...

9 years ago | 0

| accepted

Answered
Merging different arrays depending on condition
_"How can I do that effectively?"_ Like always in MATLAB, using _indexing_ is going to be simple and efficient, and storing d...

9 years ago | 3

| accepted

Answered
How to add leading zero to a letter in matlab
It is much simpler and more efficient to use <https://www.mathworks.com/help/matlab/ref/ismember.html |ismember|> or <https://ww...

9 years ago | 2

| accepted

Answered
Problem by creating Sub Matrices
The more that you set up before the loop, the neater and clearer the code will be: mat = reshape(1:25,5,5).'; % input matri...

9 years ago | 0

| accepted

Answered
Flipping the rows in a matrix to rearrange according to the weighted sum of the row
>> A=[0.6 0.4 0.9 0.7;0.8 0.7 0.9 0.5;0.8 0.6 0.5 0.4;0.8 0.5 0.6 0.5] A = 0.6 0.4 0.9 ...

9 years ago | 0

| accepted

Answered
how to find the second most repeated value in vector
>> [n,bin] = hist(x,unique(x)); >> [~,idx] = sort(-n); >> n(idx) % count instances ans = 3 2 1 1 ...

9 years ago | 4

| accepted

Answered
I want to add two binary numbers 11111101 and 0.1000, please help me..
>> binf2dec('11111101')+binf2dec('0.1') ans = 253.5 Where function dec = binf2dec(bin) tkn = regexp(b...

9 years ago | 0

Answered
Converting rectangular grids to an array
All you really need to do is use the correct order of arguments to |ndgrid|: >> nx = [1 2 3]; >> ny = [4 5 6]; >> nz ...

9 years ago | 0

Answered
I need some explanations on "regexpi" and "str2double" functions.
1) This regexp matches any single digit followed by zero or more digits or letters, followed by the letter |m|. The |'split'| op...

9 years ago | 0

| accepted

Answered
Averaging specific elements from array
You could use <https://www.mathworks.com/help/matlab/ref/dlmread.html |dlmread|> and <https://www.mathworks.com/help/matlab/ref/...

9 years ago | 0

| accepted

Answered
data storage, reduce the repeated elements, recurrence
That is called _run length encoding_. Download this: <https://www.mathworks.com/matlabcentral/fileexchange/41813-runlength> ...

9 years ago | 0

| accepted

Answered
Find values in list that appear exactly once
How about this: [tmp,idx] = sort(list); idp = diff(tmp)>0; list(idx([true;idp]&[idp;true])) If you are okay with g...

9 years ago | 0

| accepted

Answered
Text Output of m file
Method one: % <include>filename.m</include> <https://www.mathworks.com/help/matlab/matlab_prog/marking-up-matlab-comment...

9 years ago | 1

Answered
how to make a 2 files .mat become 1?
Actually it is really easy to efficiently merge two (or more) |.mat| files into one |.mat| file (to get the set union of the var...

9 years ago | 3

Answered
m1(m2 == 1), but with dimensions of m1 intact?
Method one: m3 = m1; m3(m2~=1) = NaN; Method two: m3 = NaN(size(m1)); idx = m2==1; m3(idx) = m1(idx); M...

9 years ago | 1

| accepted

Answered
Check which output arguments are requested within a function
Currently there is no inbuilt way to detect this: <https://www.mathworks.com/matlabcentral/newsreader/view_thread/325735.html...

9 years ago | 2

| accepted

Answered
Systematically add entries to vector array
Here is one efficient method, without creating any temporary variables: >> V = [1 3 5 7 1 3]; >> V(2:3,:) = 8; >> V(:...

9 years ago | 1

| accepted

Answered
How to reshape a matrix using sort
>> M = randi([0,1],25,68); >> [~,idx] = sort(sum(M,1)); >> cellplot(M(:,idx)) and use the index on the labels as well...

9 years ago | 1

| accepted

Answered
Copy/rename cell array and then rename all images again
Use |regexprep| or |strrep|, e.g.: [filenames, pathname] = uigetfile({'*.jpg'}, 'MultiSelect', 'on', 'Please select the lef...

9 years ago | 0

| accepted

Answered
how to add element to a cell array struct without loop
This would be trivially easy if you had stored your data in a <https://www.mathworks.nl/help/matlab/matlab_prog/access-multiple-...

9 years ago | 0

| accepted

Answered
Matrix call inside a for loop
If you simply put all of your data into *one* array then your task is *trivial* using indexing: Time = [0 1 1 3 3 4]; Da...

9 years ago | 0

| accepted

Answered
Dynamic approach to create a vector out of on an array based on 2 criteria in another array
>> Tnew = round(bsxfun(@times,Test,[1,365])); >> [~,idx] = ismember(Tnew(:,1), round(InterestRates(:,1))); >> [~,idy] = ...

9 years ago | 1

| accepted

Answered
switch case and menu command
The <https://www.mathworks.com/help/matlab/ref/menu.html |menu|> documentation tell us that |menu| returns the _index_ of the se...

9 years ago | 0

Answered
How to list through words in for loop.
When you put your data into *one* array then your calculations will be trivially easy. For example: M = [... 2017,07...

9 years ago | 0

| accepted

Load more