How to create a countdown timer ?
See attached demo. Adapt as needed.

7 days ago | 0

That's not big at all. Try other functions like dlmread(), readcell(), readmatrix(), importdata(). Maybe one of them will work...

7 days ago | 0

Plotting multiple functions getting an error
If you don't use syms and fplot(), you can do this: numPoints = 2000; w = linspace(0, 1000, numPoints); phase = atand(w/3)+at...

7 days ago | 0

Taking averages of only a few rows out of several?
That's kind of ambiguous. Do you want a mean from each row, so you'll get 3 values? Or do you want all 300 values to be averag...

8 days ago | 0

How to save image after encryption?
Unless your encryption produced another uint8 or uint16 image, you're probably best just saving it as a binary file with a .bin ...

8 days ago | 0

Scale on x-axis
Use the xticks(0:0.2:0.8) function: Full demo: % Create sample data. x = linspace(0, 0.8, 256); period = 0.2; y = sin(2 * p...

8 days ago | 0

Divide array into 3 parts
Maybe use this % Create sample data. N = 100 M = randi(9, N, 3) % Split matrix up into parts. [rows, columns] = size(M) en...

8 days ago | 0

In Scatter plot, make the largest data on the top
Maybe try sorting so that the higher value points are plotted last. Possibly (untested) % Sort Z so that bigger values are at ...

8 days ago | 0

Count number of blobs in rows only
I don't think that's the correct approach at all. What I'd do is to first identify the rows and columns of the centers of the p...

8 days ago | 0

| accepted

Unable to perform assignment because the left and right sides have a different number of elements.
What is size(batch(batch2_idx(i)).cycles) and what is the value of add_len(i)? Evidently they're not the same value so you're...

8 days ago | 0

Can anyone help me?
Because you have this: if 2300 > a fl = 8./a else ft = 0.0396 * a.^-0.25 end and because you never initialized ...

8 days ago | 0

Create random matrix (MATLAB)
@high speed I think what you need to do is to first construct a Latin Rectangle: https://en.wikipedia.org/wiki/Latin_rectangle ...

8 days ago | 0

Using interp1 to resample an image, results in NaN values.
@Star Strider spectra can be 2-D. For example a diffraction pattern is a 2-D spectrum. You can get a spatial frequency spectru...

8 days ago | 0

| accepted

How to plot the subplots but with less lines of code?
Try using the nexttile() function nexttile; instead of the subplot() function subplot(2, 3, j)

9 days ago | 0

use a custom distance with the kmeans
You might also consider SVM. It tries to find a dividing line between two groups such that the gap between the two groups is wi...

9 days ago | 0

How to calculate percentage of green and yellow in the image
Try this (untested) rgbImage = imread("peppers.png"); subplot(2, 2, 1); imshow(rgbImage); RGB = im2uint8(rgbImage); [gree...

9 days ago | 1

| accepted

use a custom distance with the kmeans
Here is code to randomly lay down points and draw thin black lines between a pair of points if they are far away from each other...

10 days ago | 0

| accepted

use a custom distance with the kmeans
Not sure why you think there are clusters. I'd just use pdist2() and then threshold to find points that are farther apart than ...

10 days ago | 0

Masking by pre-selected ROI and subtracting all other areas
You just need poly2mask() and regionprops(). Assuming you have your ROI in a list of (x,y) coordinates: [rows, columns, number...

10 days ago | 0

Help with for loop and if else statement
You need to index L and Q: L = linspace(0, 200, 2000); Q = ones(1, length(L)); % Initialize to 1 for k = 2 : length(L) i...

10 days ago | 1

Applying filter to 2D image using overlap and add method not working
Why not simply use conv2()? If those are the values, the image should not be all white. Try displaying final_and instead of ne...

10 days ago | 0

| accepted

How to draw a boundary line for spray image
Scan down the image to get the left edge mask = bwareafilt(mask, 1); % Get largest blob only (if you want that). [rows, column...

10 days ago | 1

| accepted

How to make a line plot with a colorbar as the third variable?
You need to have a colormap that is an N-by-3 array, not like your z which is a 1-by-4 array. Try this: % Initialization Steps...

10 days ago | 0

How to create a binary mask
Try adjusting the threshold value T in imbinarize() until you get the threshold you want: BW = imbinarize(I,T) creates a binary...

11 days ago | 0

| accepted

Can I use median filtering without put the salt & pepper noise?
Not sure what "Can I use median filtering without put the salt & pepper noise?" means, but yes, you can use medfilt2() on an ima...

11 days ago | 0

I have a 100 x 100 matrix of the number 1. I need to change the number in the 15th column, 32nd row. how do I do it.
To change it to 37, first do this: MATLAB Academy - Free 2 hour training then do this: M(32, 15) = 37;

11 days ago | 1

How can I delete certain unwanted user-defined regions/blobs in segmentation?
How about using BW2 = bwselect(BW,c,r)? Something like (untested) uiwait(helpdlg('Click on the bad blobs. Type Enter when don...

11 days ago | 0

How do I make 3D sphere for convolution?
SE = strel('sphere',r) % creates a 3-D spherical structuring element whose radius is r pixels. out = convn(inputImage, SE.Neigh...

11 days ago | 1