Answered
Need help with the code.
Try this. shuffletext2([1 2; 3 4; 5 6], 'orange') function [intext] = shuffletext2(pairs,intext) for p = 1:size(pairs,...

4 years ago | 0

Answered
Custom colorbar with predefined ticks
The answer I gave in your last question addressed this issue in part (at least for linear scales). For an arbitrary scale, you ...

4 years ago | 1

| accepted

Answered
why if elseif statement is not working
It's doing exactly what you're telling it to do. Look at the range of the data. Look at the logical tests you're doing. Case ...

4 years ago | 1

Question


A better way to do antidiagonal matrix vectorization?
Say I want to reduce a MxN matrix to a column vector, consisting of all antidiagonal vectors. Consider the 5x5 matrix: A = res...

4 years ago | 3 answers | 0

3

answers

Answered
How do I get for loop to stop creating matrix when it reaches the correct size?
I'm just going to assume the intent is something like this: N = 28; vc = [4 -1 zeros(1,N-2) -1 zeros(1,N^2-N-1)]; vr = [4 -1 ...

4 years ago | 0

Answered
Use for loop with Circshift to generate Pentadiagonal matrix
You ask for a pentadiagonal matrix, but what you describe has only three nonzero diagonals, and they aren't centered on the main...

4 years ago | 1

Answered
Pixelwise brightness adjustment using another image (weights)
This might be of use as an example. The original image has large flat regions of solid color, but the weighted image does not. ...

4 years ago | 0

Answered
What mistake I am making?
Try this m = [ 2 14 28 -7 5 ]; avgpositive7multiples_for(m) function [avg] = avgpositive7multiples_for(m) m = m(m >= ...

4 years ago | 0

Answered
summation of a matrix inside circle
This should work regardless of whether N is odd or even. s = 100; A = ones(s); % test array % build distance map rmax = s/...

4 years ago | 0

| accepted

Answered
Legend with 15 colors
I don't know what your plot type is, but consider the contourf example: % the given colormap cmap = [0.851 0.851 0.851;0.498 1...

4 years ago | 0

Answered
How do I write pdf of random variable?
The PDF for uniform random numbers is just a simple piecewise-constant function. Consider uniform random numbers with a lower b...

4 years ago | 0

Answered
Issues with morphological closing of a binary image?
Did you notice that your thresholded image is inverted? By trying to close the inverted image, you're trying to remove the wron...

4 years ago | 0

| accepted

Answered
Vectorization not working in Matlab - Matrix dimensions do no agree?
It can be simpler than that. % original T = eye(3); vec_1 = [4,5,6]; vec_2 = [7,8,9]; tot = 0; for m=1:3 for n=1:3 ...

4 years ago | 0

Answered
Extract substring in right format
Why include the extra _? str = 'Subject160/VSTMB_160_band_resample/data_22_right_average_210225_1827.mat' EventName = regexp(s...

4 years ago | 0

| accepted

Answered
how can i obtain this?
I'm assuming that you want all 71 columns to be extracted in the same fashion. Consider the example: % 5x5x3 array A = cat(3,...

4 years ago | 0

Answered
Extract X, Y and Z data from contour plot in JPEG format.
This is a routine question, it seems. This is the answer as I see it. https://www.mathworks.com/matlabcentral/answers/146003...

4 years ago | 0

Answered
How to interpolate attached data with the interval of 0.1524?
Something like this: DP = readmatrix('DepthVSpressure.txt'); D_refined = min(DP(:,1)):0.1524:max(DP(:,1)); P_refined = inte...

4 years ago | 0

Answered
For loop each RGB image channel
There are probably more succinct ways, but this is one way. Instead of creating a pile of variables, just put things in an arra...

4 years ago | 1

| accepted

Answered
how to rotate integer vector from right to left and vis versa
Something like this shamount = 1; % amount to shift left (negative to shift right) A = 1:5 % test vector B = circshift(A,[0...

4 years ago | 0

| accepted

Answered
Why is there no line on my plot ?
Use the entire vector instead of the last element. plot(prcp_rad,LSyield);

4 years ago | 0

Question


Dealing with dead newsreader links on the forum
There are countless comments and answers on the forum which link to old Mathworks newsreader threads. Of course we all know tha...

4 years ago | 0 answers | 2

0

answers

Answered
How do we upsample a colour image by 0.25 and 0.5 without using imresize() function ???
Direct subscript indexing isn't going to work, since there are no fractional indices in an array. lena_quarterup = lena_q(1:l...

4 years ago | 0

Answered
View individual components of NTSC (Y, I and Q) image
You need to assume some nominal Y and then convert back to RGB. A = imread('YIQ_components.jpg'); % original barn image monta...

4 years ago | 0

Answered
Save and Load a matrix
I don't know why nobody has thrown an answer here, but here goes. The output argument of load() is a struct. You either use ...

4 years ago | 0

Answered
Using a variable to help fill in the legend line on a plot
You can use sprintf() to construct a bit of text from numeric variables or other string/char variables. Then you can use that i...

4 years ago | 0

Answered
how to add a corresponding colorbar with a plot lines
Just flip the colormap. y=1+rand(10,10)*9; col = ones(10,3).*rand(10,1); col = sort(col,'ascend'); plot([1 10],[1 10]); h...

4 years ago | 0

| accepted

Answered
I want to put the numerical values in a 19x2 matrix and ignore the text before the numbers
You can start with textscan() fID = fopen('AER309 Lab 4 - CpData.txt', 'r'); M = textscan(fID, '%f %f','HeaderLines',3) fclos...

4 years ago | 1

| accepted

Answered
When using fspecial my figure/picture just ends up as a blue square?
You're probably starting out with a uint8-scaled image and casting it as double. At that point, you can do whatever you want wi...

4 years ago | 2

Answered
Remove white space from around image
It's never too late for reference answers ... Reading the question, I assume that the intent is to crop the excess padding from...

4 years ago | 1

Answered
How do I add a black border around an image?
Rik already gave the non-IPT and IPT methods. I'm just going to add a bunch of examples for a more generalized reference coveri...

4 years ago | 0

Load more