Solved


N-th Odious
Given index n return n-th <https://oeis.org/A000069 odious number>.

9 years ago

Answered
How to overlay a curve over histogram?
If you already have the curve, then just type |hold on| and plot it. An example: ydata = randn(1000,1); hist(ydata) hold ...

9 years ago | 0

Answered
How to create a new variable for each iteration of a while loop?
Structures are great for this kind of task (see <https://www.mathworks.com/help/matlab/ref/struct.html struct>). Here is an exam...

9 years ago | 1

Answered
How to store multiple serial objects
You certainly can store them in an array, e.g.: n = 8; s = cell(8,1); for ii=1:8 s{ii} = serial(sprintf('COM1%d',ii-...

9 years ago | 1

| accepted

Answered
How can I fix my error with the passing a function to another fuction?
The first line should be f = @(x) exp(x);

9 years ago | 0

Answered
Integration of norminv function
The problem is that |norminv(x,0,1)| goes to |-Inf| as |x| goes to zero and |Inf| as |x| goes to 1 (and ditto for |y| and |z|), ...

9 years ago | 1

| accepted

Answered
How to plot a matrix in polar coordinates with color?
I think most approaches will involve converting the coordinates to Cartesian. Here is one approach: v0=10; A=4.*v0./pi;k=1;...

9 years ago | 1

| accepted

Answered
Nonlinear Tangent (trigonemetric) equation
Before trying to find zeros for a function, it's a good idea to plot it so you understand the nature of the problem. If you do t...

9 years ago | 0

Solved


Put two time series onto the same time basis
Use interpolation to align two time series onto the same time vector. This is a problem that comes up in <http://www.mathwork...

9 years ago

Solved


intersection of matrices
Given two matrices filled with ones and zeros, determine if they share a common row, column entry. These matrices are of identi...

9 years ago

Answered
How to calculate the integral of a function with a spline in it
For evenly or unevenly spaced data, you could use the trapezoidal rule (MATLAB function <https://www.mathworks.com/help/matlab/r...

9 years ago | 0

Answered
Offseting the y axis to make data more clear
After yyaxis right; use a command like ylim([-0.1 1.5]) to move the axes.

9 years ago | 0

Answered
Logical Test on Matrix Failing
The variable |little_endian_message| is a char representation of binary numbers. Try this: if( little_endian_message(a) =...

9 years ago | 0

Answered
Plots with stairs and inclines?
I'm not sure how you intend to generate the points, but for the example plot you gave, |plot| works just fine with an appropriat...

9 years ago | 1

| accepted

Answered
Quiver Plot Arrows too Wide
Have you tried looking at <https://www.mathworks.com/help/matlab/ref/quiver.html the documentation for quiver>? There is an opti...

9 years ago | 0

Solved


Get me!
Inspired by Now! problems. Do your best!

9 years ago

Answered
Collection many vectors in one matrix
The answer is G = [I1; I2; I3]; See <https://www.mathworks.com/help/matlab/math/creating-and-co%E2%80%A6 Creating and Co...

9 years ago | 1

| accepted

Answered
How can I speed my function?
One source of delays can be |repmat|. This can be replaced by a suitable choice of index, as in the following: r = R(i,:); ...

9 years ago | 1

| accepted

Answered
Overwriting While-loop conditional with +Inf
MATLAB evaluates a logical expression like your |while| condition from left to right. If |a==1|, it knows the expression is fals...

9 years ago | 0

Answered
How to Simplify an symbolic expression
If I define a= 2*atan((-2+sqrt(4-gama^2 *l^2* M^2-4* gama *l* M^2 *tan(gama/2)+4* tan(gama/2)^2-4 *M^2 *tan(gama/2)^2))/(ga...

9 years ago | 0

Answered
How to load *.mat file from each directories in new script?
Here is a solution that assumes there is one of these |.mat| files in every subdirectory of each of the 15 directories. Let's al...

9 years ago | 0

Answered
Old form of legend('string 1','string 2',2) ??
Actually, it's NW (see the <http://www.mathworks.com/help/releases/R13sp2/techdoc/ref/legend.html?s_tid=srchtitle documentation ...

9 years ago | 1

| accepted

Answered
Finding normals to contours on contour plot
You want curves to follow the gradients. It's easy enough to <https://www.mathworks.com/help/matlab/creating_plots/display-quive...

9 years ago | 0

Answered
How do I set the limits on the secondary y axis?
Use <https://www.mathworks.com/help/matlab/ref/ylim.html ylim> right after |yyaxis right|.

9 years ago | 2

| accepted

Answered
Extract matrices out of a symbolic matrix
It looks like you are trying to extract the diagonal, upper triangular and lower triangular parts of the matrix. These commands ...

9 years ago | 0

| accepted

Answered
Results showing up as NaN
Here is one source of NaN's: In |slipratio_fun| with the initial value of |t=0| and |v=0|, you have |omega=v=0|. The line ...

9 years ago | 0

| accepted

Answered
Warning: The solutions are parameterized by the symbols: z
The function |solve| is part of the Symbolic Math Toolbox. Are you defining the symbolic variables? If I run this code syms...

9 years ago | 0

| accepted

Answered
How to calculate value using different matrix using if and for loop
In the line if abs(b) < 14.5 the condition is looking at the entire 100 x 1 vector |b|, and the condition is only true i...

9 years ago | 0

| accepted

Solved


Sum of odd numbers in a matrix
Find the sum of all the odd numbers in a matrix. Example x = [2 3 5 7 1 4 11] y = 27

9 years ago

Solved


Back to basics - mean of corner elements of a matrix
Calculate the mean of corner elements of a matrix. e.g. a=[1 2 3; 4 5 6; 7 8 9;] Mean = (1+3+7+9)/4 = 5

9 years ago

Load more