Answered
Grep a numeric array from a text file
>> str = '[(1, 2, 3), (4, 5, 6, 7), (8, 9)]'; >> str2double(regexp(str,'\d+','match')) ans = 1 2 3 4 5 6...

9 years ago | 0

| accepted

Answered
How to build a matrix like this
>> N = 4; >> V = N:-1:1; >> bsxfun(@min,V,repmat(V(:),1,N)) ans = 4 3 2 1 3 3 2 ...

9 years ago | 1

Answered
how to read multiple pgm images ?
Something like this perhaps (untested): P = 'C:\Users\kitty\Dropbox\non negative factorization\faces\face.test\test\face'; ...

9 years ago | 0

| accepted

Answered
how to solve the fopen error?
# Use <https://www.mathworks.com/help/matlab/ref/fullfile.html |fullfile|> instead of the rather inappropriate |strcat|. # Retu...

9 years ago | 1

| accepted

Answered
Fill cell in second column based on first column cell array
*Method one: <https://www.mathworks.com/help/matlab/ref/regexp.html |regexp|> and convert using subtraction:* >> C = {'9_X_...

9 years ago | 0

| accepted

Answered
How to split a vector in to sub vectors?
Simpler: >> v = rand(8812,1); >> b = 20; % block size >> n = numel(v); >> c = mat2cell(v,diff([0:b:n-1,n])); >>...

9 years ago | 3

| accepted

Answered
Merge cell arrays in a loop
The trick is to load each |.mat| file into a structure, which you can then access the fields of: C = cell(1,numel(list); ...

9 years ago | 1

| accepted

Answered
ind2sub is not working properly.
Your function |PeLRTfusion| returns different outputs values depending on the size of the inputs: >> [v,x] = min(fun(LamdaS...

9 years ago | 0

| accepted

Answered
Applying equation to each field in a structure
Personally I would define a simple <https://www.mathworks.com/help/matlab/matlab_prog/anonymous-functions.html anonymous functio...

9 years ago | 0

Answered
Why is the pause function not activating?
The reason is because mod(step,20) will never output the value 20, and so your comparison mod(step,20)==20 will ...

9 years ago | 2

Answered
Number consecutively a matrix row-wise
>> M=NaN(5,7); M(1,3:5)=1; M(2,3:6)=2; M(3,1:4)=23; M(4,5:7)=75; *Method one: <https://www.mathworks.com/help/matlab/ref/fi...

9 years ago | 0

| accepted

Answered
How to extract data from a cell array which contains structs?
Something like this might work for you: cell2mat(cellfun(@(s)s.field,C,'uni',0)) it assumes that the data is able to be ...

9 years ago | 1

| accepted

Answered
How can i have subvectors ?
>> A = [1,3,5,4,2,8,9]; >> X = cumsum([1,0,diff(diff(A)>=0)~=0]); >> Z = accumarray(X(:),A(:),[],@(n){n}); >> Z{:} ...

9 years ago | 3

Answered
Store multiple variables for loop
The basic problem is trying to put them all data into the same array. While it would be _possible_ to put strings (1xN char) int...

9 years ago | 0

Answered
How can i make Subscript indices to be real positive integers or logicals.from the codes below.
MATLAB does not have implicit multiplication. So this: K2(beta*wedgem-K3*mu2) needs to be this: K2*(beta*wedgem-K3*...

9 years ago | 0

Answered
Subtracting Row and column vectors
One simple solution that does not require knowing anything about the sizes of the vectors: >> A = randi(9,1,9) A = ...

9 years ago | 0

Answered
How to use a floating point number in max() function?
aspectRatio = allWidths./allHeights; idx = aspectRatio>0.5 & aspectRatio<1.5; |find| is likely not required, as logical ...

9 years ago | 0

| accepted

Answered
Problems repeating matrix in desired order
A(:,:,1) = [1,2;3,4]; A(:,:,2) = [5,6;7,8]; N = 2; repmat(permute(A,[1,2,4,3]),[1,1,N,1]) which gives exactly the ...

9 years ago | 0

| accepted

Answered
I have 12 matrix. I need to find the the max occurring value in each element position. Please help.
Put all of your data into one array (as it should be anyway): A = cat(3,M1,M2,...) or put it into *one* array when impor...

9 years ago | 0

Answered
specify rows and columns to find min value?
>> N = [0,1,5,12,1;1,23,4,75,5;11,29,2,5,9;23,3,5,8,0;12,11,23,48,0]; >> RC = [1,3;2,5;2,3;5,1;2,4;1,1;1,5;3,3]; >> [val...

9 years ago | 0

Answered
I wanna save figure using 'saveas' without making white-background
As the documentation clearly states, <https://www.mathworks.com/help/matlab/ref/saveas.html |saveas|> saves the _figure_: this i...

9 years ago | 0

Answered
quick overview over a variable (e.g. struct)
Simply call <https://www.mathworks.com/help/matlab/ref/fieldnames.html |fieldnames|>: fieldnames(S)

9 years ago | 1

| accepted

Answered
help fget1 says the function does not exist. I am using Matlab 2017a, what can be the problem?
You need fgetl not fget1 (that is the lowercase L, not the number one).

9 years ago | 2

| accepted

Answered
What version of matlab was the flag to omit NaNs in sum (also var, mean, etc) first introduced?
It is in the documentation: <https://www.mathworks.com/help/matlab/release-notes.html> and search for "omitnan" to find th...

9 years ago | 2

Answered
group an array according a condition
You could use <https://www.mathworks.com/help/matlab/ref/accumarray.html |accumarray|>: A = [ 2 10 10.1 12 14...

9 years ago | 1

Answered
Problem with MATLAB "exist", returning 0, although the file actually exists!
This will fix it: D = 'D:\2nd year\C0001.tifroiSTR1'; S = dir(fullfile(D,'*.jpg')); for k = 1:numel(S); [~,nam...

9 years ago | 2

| accepted

Answered
How do Iget a list from multiple rows?
Using a regular expression is trivially easy: >> data = {'he is #coming #today'; 'will #it rain?'}; >> C = regexpi(data,...

9 years ago | 1

Answered
Function: From multiple variables as input to vector input
Either rewrite the function exactly as you have shown, or put it inside a wrapper: foo = @(x)fun(x(1),x(2)); Note the d...

9 years ago | 2

| accepted

Answered
How to sort the output of variables of cell array ?
If it is a vector, why not simply use <https://www.mathworks.com/help/matlab/ref/sort.html |sort|>?: >> sort(fx1) ans = ...

9 years ago | 1

| accepted

Load more