Answered
How do i place a 9-by-9 matrix in the center of a 256-by-256 matrix of zeros. Thank you
Try this: M = zeros(255); M(123:132, 123:132) = randi(9); figure(1) imagesc(M) axis image grid You c...

9 years ago | 0

| accepted

Answered
Mathematical Model for eliminating pollutes from the great lakes. (I need coding help)
I don’t know anything about Great Lakes hydrodynamics, and I’m not certain what you are asking or what you want, so this is a _g...

9 years ago | 0

Answered
Creating random values with 2 Variable-precision accuracy in Matlab
Either of these will work: A = 0.17; B = 0.87; unirnd2 = round(unifrnd(A, B, 1, 10), 2); % With The Mo...

9 years ago | 1

| accepted

Answered
Error plotting my graph.
Use *|fplot|* (with a single value for *|‘omega’|*) or *|fsurf|* (with a range of values for *|‘omega’|*). This works: ...

9 years ago | 0

Answered
Optimising 3 variables to produce minimal errors
I would change *|‘minfunc’|* to define: F = dsum; You might find that more applicable to your problem if you want to mi...

9 years ago | 0

| accepted

Answered
Two-line y-label with Latex interpreter not centred properly
This works for me (in *|R2017b|*): figure plot(0:10,0:10) ylabel({'line 1 of label','line 2 (Suppose I want just \it...

9 years ago | 0

| accepted

Answered
Error using ones Size inputs must be integers.
To force them to be integers, use *|fix|*, *|floor|*, *|ceil|*, or *|round|*. *_Example_ —* K1 = ones(fix(length(stri...

9 years ago | 1

Answered
Error: Vectors must be the same length.
The easy solution is to use the *|linspace|* function to make them all the same lengths: t1 = linspace(0, 2.5, 250); t2...

9 years ago | 2

| accepted

Answered
How can I write a loop that performs a function to each element in a vector?
Ideally, you would write your function so that it would allow vectorized operations. If that is not an option try something...

9 years ago | 0

| accepted

Answered
Help with stem different colors
If you just want the vertical lines without the markers: stem(0:1:51, y, 'r-', 'Marker','none') If you want the markers...

9 years ago | 0

| accepted

Answered
Hi..i need to repeat rows and columns in matrix A
Try this: After = repelem(A', 1, 2) After = 1 1 4 4 2 2 5 5 3 ...

9 years ago | 0

| accepted

Answered
Dimension of matrices being concatenanted is not consistent.. PLease hellp !!!
I would use a cell array, that you can create by changing the square brackets *|[]|* by curly braces *|{}|*: letters={'a';...

9 years ago | 0

| accepted

Answered
Find values outside of a range when calculating residuals.
I would use ‘logical indexing’ here: L = (res>=-3) & (res<3); % Logical Index Of ‘res’ Values Within Limits...

9 years ago | 0

| accepted

Answered
Probability Density Function (PDF) plot
See if the <https://www.mathworks.com/help/stats/ecdf.html *|ecdf|*> (link) function and related functions such as <https://www....

9 years ago | 0

| accepted

Answered
How can I create a rose plot showing the distribution of the values?
Choose fewer elements for *|‘theta’|*: theta = linspace(0, 2*pi, 435); Experiment to get the result you want.

9 years ago | 0

| accepted

Answered
Need help debugging an error with Latex Interpreter and sprintf
You need to use two consecutive *|\\|* in *|fprintf|* and *|sprintf|*. This works: title(sprintf('Pressure $(1-M_\\in...

9 years ago | 2

| accepted

Answered
Please help with Index exceeds matrix dimensions error
This will eliminate the error: for n = 2:length(x)-2 y(n+1)=(-1/3)*x(n+2)+(1/2)*x(n+1)+(1/3)*x(n)+y(n); end h...

9 years ago | 0

| accepted

Answered
How can I find a maximum mean value of row with given 2D array?
Try this: max_mean_row_idx = find(mean(S,2) == max(mean(S,2))) max_mean_row = mean(S(max_mean_row_idx,:),2) if there...

9 years ago | 0

| accepted

Answered
how can I find the minimum of a function with two matrix as its input?
One option: D=[1 0;0 1]; Y=[0;0]; fun = @(lambda) norm(Y-(lambda.*D)*[-1;-1]); [lambda, fval]=fminsearch(...

9 years ago | 0

Answered
How can I find the center of random coordinates?
It depends on what you mean by ‘center’, The *_centroid_* of your point cloud is simply the mean of them in every dimension. ...

9 years ago | 1

Answered
Find rows in a matrix that are not duplicates
I admit I’m a bit lost in your description of what you want to do. That said, I’d use the <https://www.mathworks.com/help/m...

9 years ago | 0

Answered
sound peak or gaussion or delta
You do not hear it because as a single Gaussian pulse, it is far below the range of human hearing, and probably below the abilit...

9 years ago | 0

Answered
How do I plot this square?
Since it’s not homework, here you go: figure(1) patch([1 3 3 1], [2 2 4 4],'r') hold on plot([1 3], [2 4], ':b'...

9 years ago | 1

Answered
Can anyone help me solve this simple equation in matlab.
Try this: fcn = @(x,y) log10(y)+y - x; x = 3; [y,fval] = fzero(@(y)fcn(x,y), 10) y = 2.5872 fv...

9 years ago | 0

Answered
How can I change the significance level of either kruskalwallis or ranksum test?
For *|ranksum|*, you have to specify it as a name-value pair as <https://www.mathworks.com/help/stats/ranksum.html?s_tid=doc_ta#...

9 years ago | 0

| accepted

Answered
Error in odearguments among other errors
Note that <https://www.mathworks.com/help/symbolic/rhs.html *|rhs|*> (link) is a funciton in the Symbolic Math Toolbox. If you ...

9 years ago | 0

Answered
Looking for additional 2017 documentation
See the *|R2017b|* documentation on <https://www.mathworks.com/help/matlab/desktop-tools-and-development-environment.html *Deskt...

9 years ago | 0

Answered
Grouping variables from char.
If you put your data in a categorical array (see the documentation on <https://www.mathworks.com/help/matlab/categorical-arrays....

9 years ago | 0

Answered
how to make fft of rectangular function?
Small error in *|figure(3)|*. You do not need *|figure(2)|*. This works: Ts = 0.01; N=2000; t=-20:Ts:(N-1)*Ts; T ...

9 years ago | 3

Answered
Bars showing the measurement periods for oceanography data
I do not know what your data are. This works: XData = sort(randi(9, 10, 2),2); % Creat...

9 years ago | 2

| accepted

Load more