Extracting certain values from a cell array with nth columns containing double arrays
mC = cellfun(@(x)max(x(:,3)),C)

2 months ago | 0

| accepted

Finding length between two array elements.
The RunLength utility from the File Exchange might be handy. Run it in a loop over each column.

2 months ago | 0

Draw vertical lines on a plot
If you have R2018b or later, you can use the xline command. If you have an earlier version, you can use the line command (which...

2 months ago | 0

Beginner's question about data plot
Try this instead plot(time,Enable_d,'.','MarkerSize',32) This code will plot individual points, without a connecting line.

2 months ago | 0

find max of vector
m = max(v); idx = find(v==m);

2 months ago | 0

How can vectorize the below codes?
Well, not vectorizing it, but if you preallocate etas and phis with these line: etas = zeros(262144,2); phis = zeros(262144,2)...

2 months ago | 0

| accepted

Dear friends, the long matlab command that I have written is error. I want to be spelled the same way but without error.
Do it like the second example on this documentation page about continuing long statements on multiple lines.

2 months ago | 1

| accepted

Simple if statement also executes if condition not met - What am I doing wrong?
I ran the following code: dist_psd = [1 1 1 1 NaN]; time_psd = [1 1 1 NaN NaN]; for i = 1:length(dist_psd); if (isna...

2 months ago | 0

| accepted

update vector with nubers from another vector
A = [ 2 4 6 10 15]; B = [2.43 2.3 12 5.1]; [~,idx] = min(abs(B'-A),[],2); B = A(idx)

2 months ago | 1

| accepted

Sorting numbers in an array without sort function
if all(diff(X)) >= 0 Also, rather than defining the finished variable, you could have just made that the condition for the whil...

2 months ago | 0

i want to know whats is the problem in this code during running
Are you trying to just paste that code into the command line, and running it? Instead, you should save that function code into ...

2 months ago | 0

how to remove zeros from the matrix?
I think this does what you want: % Replicate A into B B = A; % For the even-numbered rows, circularly shift the elements B...

2 months ago | 1

| accepted

Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 2-by-2.
In the line of code giving the error: A(i,j)=(0.5)*(c)*(Cla).*(C(i,j))+k(i,j) you are using the full matrix c. Maybe you wante...

2 months ago | 0

Detecting length and number of occurrences in a logical array
Download Jan's RunLength utility from the File Exchange. It will do exactly what you want. array1 = [0 0 0 0 0 1 1 1 1 0 0 1 1 ...

2 months ago | 0

| accepted

Dark Mode editor for MATLAB
The best way that I know of to do this is to use MATLAB Schemer from the File Exchange.

2 months ago | 0

| accepted

How to terminate the loop
Due to floating-point error, it may be that the condition if p_f_BM == 1 is not exactly met. With floating-point numbers, it's...

2 months ago | 0

| accepted

If I work on a different computer everytime, is there a way to save my shortcut codes (ie all the plot formatting stuff that's always the same) on my math works account so I can pull it up on Matlab?
I think you could probably use MATLAB Drive to do what you want. You could also store your code in a git repository, including ...

2 months ago | 0

| accepted

What is the s_rot() function ?
That is not part of base MATLAB or any MathWorks toolbox, as far as I could find. Googling on "s_rot" matlab found a few hi...

2 months ago | 1

| accepted

machine learning for medical data analysis
That is a function from the Image Processing Toolbox. You should check to see if you have that toolbox installed and licensed. ...

2 months ago | 0

| accepted

Not Converting ASCII to DECIMAL
c = b-'0'

2 months ago | 0

sorting array without min and max
Take your pick: Sorting algorithms Enjoy this video as well.

2 months ago | 0

Count number of times value appears in column
% Parameterize the max value, for convenience V = 296; % Some simulated data FinalRanking = randi(V,1000,V); % Prealloca...

2 months ago | 1

| accepted

Generating random number for the Inverse Gaussian distribution
If you have the Statistics and Machine Learning Toolbox, then you can generate N random numbers with N = 1000; % Set this to th...

2 months ago | 0

| accepted

Understanding standard deviation code
As explained clearly in the documentation for std: The "0" specifies that the standard deviation will be weighted by sqrt(N-1),...

2 months ago | 2

niftiread is a function from the Image Processing Toolbox. Do you have that toolbox installed and licensed?

2 months ago | 0

How to concatenate cell array without causing nested cell array
% Input data years = [2007 2008 2005 2006 2007 2008 2005 2006 2007 2008]; % Initialize the first cell with the first year c...

2 months ago | 0

| accepted

Insert Interpolation Into Matlab Code
Here is my best guess at what you should do, to get what you want: Take the x argument out of the call to interp1 Change the d...

2 months ago | 0

| accepted

MatLab PCA-LDA Code
If you have the Statistics and Machine Learning Toolbox, then you can use the built-in pca function. I'm not sure what you mean...

2 months ago | 0

How to generate rayleigh random variables with specified mean value having minimum value?
If you have the Statistics and Machine Learning Toolbox, then you can generate n Rayleigh-distributed random numbers using the r...

2 months ago | 0

| accepted