Solved


Add two numbers
Given a and b, return the sum a+b in c.

10 years ago

Solved


Select every other element of a vector
Write a function which returns every other element of the vector passed in. That is, it returns the all odd-numbered elements, s...

10 years ago

Answered
how to count number of repeating's in data series.
This code A = [22 24 24 36 36 36 48 48 48 48 24 33 22 22]'; C = accumarray(A,1); I = unique(A); counts = [I,C(I)] ...

10 years ago | 3

Answered
how can i plot probability density distribution of f(x)=20000/(x+100)^3, x>0 ? thanks for the help
Like this: x = linspace(0,1000); fx=20000./(x+100).^3; plot(x,fx);

10 years ago | 3

| accepted

Solved


Determine if input is odd
Given the input n, return true if n is odd or false if n is even.

10 years ago

Solved


Make the vector [1 2 3 4 5 6 7 8 9 10]
In MATLAB, you create a vector by enclosing the elements in square brackets like so: x = [1 2 3 4] Commas are optional, s...

10 years ago

Solved


Times 2 - START HERE
Try out this test problem first. Given the variable x as your input, multiply it by two and put the result in y. Examples:...

10 years ago

Solved


Find the sum of all the numbers of the input vector
Find the sum of all the numbers of the input vector x. Examples: Input x = [1 2 3 5] Output y is 11 Input x ...

10 years ago

Answered
Copy certain number from one matrix to another
This version only requires one instance of ARRAYFUN A = [1:12;2,1,1,2,2,2,1,1,2,2,2,1]'; I = (A(:,2)==2); J = dif...

10 years ago | 4

Answered
How to calculate the errors of histogram?
Just sum the errors that belong to the specific bins: assume in bin1 are counted data x2,x6,x7,x9, then error_bin1 = e2+e6...

10 years ago | 3

| accepted

Answered
Solving complex nonpolynomial equation and find all complex roots
To find all solutions you need global solvers, but they don't exist.. One thing that you can do is trying to initialize *fsolve*...

10 years ago | 3

Answered
What method does Matlab use to compute an approximation of an integral which contain singularities?
<https://www.mathworks.com/moler/quad.pdf>

10 years ago | 3

| accepted

Answered
How to stop a matlab process, if it exceeds certain time threshold?
<https://it.mathworks.com/help/matlab/ref/tic.html> <https://it.mathworks.com/help/matlab/ref/toc.html>

10 years ago | 3

Answered
How to add all values greater than specific value in coloumn vector ?
If A is your vector, simply do s = sum(A(A>1));

10 years ago | 4

| accepted

Answered
write image and display
Do this. H=zeros(100); H(:,10:20)=1; H(:,80:90)=1; H(46:55,10:90)=1; imagesc(H); axis image; It should be th...

10 years ago | 3

| accepted

Answered
Finding patterns in my array
Assume A is you matrix with values from 1 to 5. You can map automatically the entries having the same value in this way: C ...

10 years ago | 3

| accepted

Answered
Splitting up a matrix - how can I do it more efficient?
This will do your work efficiently. %matrix size n = 200; m = 8; %number of rows to cut t = 20; %generate ma...

10 years ago | 5

| accepted

Answered
slash / after text .txt
Just print it before closing the file. % open your file for writing fid = fopen('test.txt','wt'); fprintf(fid,...

10 years ago | 4

| accepted

Answered
How to interpolate a function out of an array of measured points
This signal is very regular. You can decompose it by sine of cosine series, and just keep the dominant terms. An alternative is ...

10 years ago | 3

| accepted

Answered
I have to get the x values for peaks occuring in my plot? What will be the code for that?
There is Matlab function *findpeaks* <https://it.mathworks.com/help/signal/ref/findpeaks.html>

10 years ago | 3

| accepted

Answered
Array values not corresponding to condition
Your problems only arise because you used only "<" operators, so the numbers that are exactly in the middle of your intervals do...

10 years ago | 3

| accepted

Answered
Get the input text bold
Open MATLAB, select the HOME tab, click on PREFERENCES. On the left of the window appearing, click on FONTS and select what you...

10 years ago | 1

Answered
Text cutting in the colorbar.
To export nice figures in Matalb, use this: <https://it.mathworks.com/matlabcentral/fileexchange/23629-export-fig>

10 years ago | 3

| accepted

Answered
Populating a matrix with variables
Best way to populate diagonal matrix is to use *spdiags* (see help page). For example, to obtain A=[1,2,0,0,0,0; ...

10 years ago | 3

Answered
Error using ./ Matrix dimensions must agree.
To achieve what you want, you have to generate all possible copules of values from x and r (no matter their sizes). Given your v...

10 years ago | 3

Answered
How to rotate a rectangle until one of the edges is parallel to the x-axis (with unknown rotation angle)?
To find the angle between the edge of the rectangle and the x-axis do simply (using your notation for vertex as x,y): c=[x(...

10 years ago | 4

| accepted

Answered
hist3 not returning expected output (weird range for indices etc)
The behaviour of hist3 is correct. Think about this: in the first dimension (say "x") you only have one coordinate number that r...

10 years ago | 4

| accepted

Answered
What is the matrix operation mnrval does with its inputs?
The reference in the Matlab help page for *mnrval* <https://it.mathworks.com/help/stats/mnrval.html> is McCullagh, P.,...

10 years ago | 3

| accepted

Load more