Answered
Trying to break apart date string
>> val = 2.016010100000000e+11; >> str = sprintf('%u',val) str = 201601010000 >> vec = datevec(str,'yyyymmddHHMM') ...

8 years ago | 0

| accepted

Answered
Colormap setting the colors i want
You can easily _adjust_ colormaps by using the |colormapeditor|: <http://www.mathworks.com/help/matlab/ref/colormapeditor.htm...

8 years ago | 1

| accepted

Answered
dir([num2str(d) '\*.png']
It searches for files name with the file extension |.png| that are located in the directory |d|. dir([num2str(d) '\*.png'] ...

8 years ago | 0

Answered
Table name from input to loop
Rather than magically defning variable names it is much simpler to use basic MATLAB indexing and a cell array |T|: D = 'Pat...

8 years ago | 0

| accepted

Answered
when i create a 3D cone with mesh function, the axes change when i change the radius.How to avoid this auto scaling of axes
Set the axes limit mode and/or values: doc xlim doc ylim doc zilm

8 years ago | 0

Answered
Sum vector to each vector row in cell array
For MATLAB versions R2016b+: cellfun(@(m)m+[0,0,1],A,'uni',0) For earlier versions: cellfun(@(m)bsxfun(@plus,m,[0,0...

8 years ago | 0

| accepted

Answered
How to use firs value from array column when threshold is reached without for loop?
This actually returns the requested matrix, and follows the description in the question: >> thr = 0; >> D = [-2,2,3,-1,-...

8 years ago | 0

| accepted

Answered
Reshape a 4D array to a 2D matrix where the size of the arrays vary
You can use <https://www.mathworks.com/help/matlab/ref/permute.html |permute|> and <https://www.mathworks.com/help/matlab/ref/re...

8 years ago | 0

| accepted

Answered
Passing parameters to plot() and axes() functions?
Simple option: use |varargin|: function myplot(X,Y,varargin) plot(X, Y, 'r', varargin{:}) More complex option: conver...

8 years ago | 2

Answered
Merge relative cells elements into single cell
D = cellfun(@vertcat,A,B,C,'UniformOutput',false);

8 years ago | 1

| accepted

Answered
Output argument (and maybe others) not assigned during call to
Rather than magically making variables appear in the workspace, always |load| into an output variable: S = load('gfp_colorm...

8 years ago | 0

Answered
Wanting to isolate a number from a string
>> str = 'ZYXW1_4.0kHz_1_P.tif'; >> regexprep(str,'^.*_(\d+\.?\d*)\D+_(\d+)_\D+$','($1,$2)') ans = (4.0,1)

8 years ago | 1

| accepted

Answered
Loop output not saving to a cell array. Only last solution saving to cell
You only need one loop: vec = 0:0.15:0.75; cnew = cell(numel(vec),1); for iter = 1:numel(vec) y = vec(iter); ...

8 years ago | 0

| accepted

Answered
use piecewise to restrict the domain of a function
An alternative to using the symbolic toolbox is to use basic MATLAB indexing: >> [X,Y] = meshgrid(-10:.5:10); >> Z = (10...

8 years ago | 0

| accepted

Answered
How to interpolate in between known data points..?
% Data: Y = peaks(100); x = 1:size(Y,2); y = Y(50,:); y(40:50) = 0; % Interpolate zeros: idx = y~=0; yn =...

8 years ago | 2

| accepted

Answered
not enought input arguments
comas_a_puntos ("/Users/cristinaserrrano...") ^ get rid of this space character! Why the space makes a dif...

8 years ago | 1

| accepted

Answered
str2double goes wrong for very large numbers
|'1032400774240044774'| has nineteen digits, which is greater than <https://www.mathworks.com/help/matlab/ref/flintmax.html |fli...

8 years ago | 1

| accepted

Answered
How to pad extra 0 after 5 consecutive 1's in an array
Simpler: >> a = [0 1 1 1 1 1 0 1 1 1 1 1 1 0 0 1 1 1 1 1 0]; >> b = regexprep(char(a+'0'),'11111','111110')-'0' b = ...

8 years ago | 2

| accepted

Answered
How do I access a field on a struct which is not always in the same level?
This is easy with <https://www.mathworks.com/help/matlab/ref/getfield.html |getfield|>, you just need to define a cell array of ...

8 years ago | 1

Answered
How to extract a specific data value from a field in a from multiple structures, and save into an array
Once you have your structures in a cell array |C| (easily achieved when importing), then this is trivial: arr = nan(1,200);...

8 years ago | 0

| accepted

Answered
How to store loop results where loop does not have whole numbers only
The easiest and most robust solution is to move those values into their own variable, defined before the loop. Then you can simp...

8 years ago | 0

| accepted

Answered
How to check the variables are equal or not?
You have to use == or isequal or strcmp or ismember or any other function that compares variables...

8 years ago | 0

| accepted

Answered
Use cell array contents to name new cell array
It is much simpler to use indexing: %Gives sheet names and rows with data [~,sheets] = xlsfinfo('Teco.xlsx'); N = num...

8 years ago | 0

Answered
multiple arrays in one result
Where |C| is your cell array: vertcat(C{:})

8 years ago | 0

Answered
Repmat a vector n times where n is not a whole number
To take the smaller index (equivalent to |fix|): >> y = 1:10; >> n = 4.2; >> [repmat(y,1,fix(n)),y(1:numel(y)*mod(n,1...

8 years ago | 0

| accepted

Answered
How to 'nest' unnested cells of various lengths?
To change the nested cell of char vectors into a numeric array: cellfun(@str2double,C,'uni',0)

8 years ago | 0

| accepted

Answered
hold value of multiplication of two scalar vector
Simpler (for R2016b and later): gamma(:) .* tao or for older versions: bsxfun(@times,gamma(:),tao)

8 years ago | 0

Answered
How to create multiple data structures
A much better idea would be to put them into *one* structure (or cell array): [U,~,X] = unique(A); C = accumarray(X(:),B...

8 years ago | 0

Answered
Functions with outputs not separated by commas
The two are essentially equivalent. But using space characters is not recommended, because it is much easier to make mistakes an...

8 years ago | 0

Answered
Get the name of picture
It is easy to convert to a numeric array: P = 'MyPath'; S = dir(fullfile(P,'*.jpg')); N = {S.name}; [~,F] = cellfun(@filepar...

8 years ago | 0

| accepted

Load more