Answered
Putting one matrix a varying number of times along the diagonal of another matrix
A = rand(3); n = 50; Acell = repmat({sparse(A)},[1,n]); B = blkdiag(Acell{:}); spy(B) Note that I made A sparse in there, s...

4 years ago | 0

| accepted

Answered
How to use File exchange
It does not matter that you use a mac or not. Save the top level folder on your search path. So use pathtool or addpath. Then sa...

4 years ago | 0

Answered
Hello, I did a for loop but my friend told me it is not the correct matlab syntax. Can anyone help me the for loop is in the description below:
for xa=1; This is not a loop. It does nothing but assign the value 1 to the variable xa. NOTHING. No loop. Instead, it looks l...

4 years ago | 0

Answered
Output Symbolic Trig Math in Degrees
If you use cos and sin, terms like this are meaningless, if the 90 is a number in degrees. Well, let me just say you will get me...

4 years ago | 0

Answered
out of memory error
Um, 1e20 rows? Seriously? Do you have that much memory? Clearly not, since your computer is throwing up at an 1e8 by 27 array. E...

4 years ago | 3

Answered
How to numerically integrate the planar equations of motion?
You need to learn how to write a function handle. What you wrote was incorrect syntax. Do you see the spare comma, AFTER the par...

4 years ago | 1

Answered
Converting to scientific notation in matlab
We are not a "team". We are just a number of people who act as complete volunteers, individually. You cannot "represent" it tha...

4 years ago | 0

| accepted

Answered
Why the result in curve fitting tool shows a different graph in plot?
@Hao Tu (This is only a followup, and since you already understand the issue, merely a clarification to Steven's accurate answe...

4 years ago | 2

Answered
What is the difference between backward slash vs forward slash in MATLAB?
BOTH of them are linear algebraic solutions. Where matrices are involved, they solve subtly different problems. A\b solves the ...

4 years ago | 2

Answered
Fmincon makes an extremely big jump in parameter search
I think you do not understand how an optimization tool works. Those first calls to your objective are there to differentiate it...

4 years ago | 1

| accepted

Answered
How to smoothen a plot?
Simple. Delete the points in the beginning of the curve that give you the spikes. WTP? They will be easy enough to spot, as they...

4 years ago | 0

Answered
How to write code for Assignment problem using GA matlab tool.
Does GA allow you to specify that some variables are integer? (Yes.) Does GA allow you to specify lower and upper bound limits ...

4 years ago | 0

Answered
Solving a System of Trig Equations
If the only unknown is theta1, then what is y? If you actually have a value for y, then you have two equations in one unknown v...

4 years ago | 0

Answered
Solve Equation and Plot it
Easy peasy. Essentially one line of code once you define the various constants. syms f_1 f_2 alpha = 0.4207; skalar = 4.5375;...

4 years ago | 0

Answered
Declrarion of an array using tilde (~). what is the correct way of using it, because my code prompts me incorrect use of tilde.
This is a test: if i == D(k) It is the correct way to use == because == is a comparison operator. However, this other line is...

4 years ago | 1

Answered
Methods to create arrays of NaN
A NaN is a nan. A NaN by any other name, is still just a NaN. But there are faster and slower ways to make them, and surely the...

4 years ago | 0

Answered
maximization problem , fmincon optimization
syms x y objxy = ( -.858*x-.04182*y-1.645*sqrt((.5882*x -.055*y).^2 + (-.0558*x +.352*y).^2 )); If x+y == 1 then we can replac...

4 years ago | 1

| accepted

Answered
How can I plot f(x,y) in xy plane
help fsurf

4 years ago | 0

| accepted

Answered
Should we always search for the global minima in our optimization problem?
Yes. And, no. Amazing how the anwer is often, well, it depends... You do want to find the true global min. Yes, that makes sens...

4 years ago | 1

| accepted

Answered
Find smallest Eigenvalue and the corresponding eigenvector.
Just compute the matrix Ainv = inv(A); Now use your code on the matrix Ainv. This works because the smallest eigenvalue is no...

4 years ago | 1

| accepted

Answered
How to store values in summation for loop?
You understand how to index a variable, thus k(i). But when you write this: s = s + (stuff) It increments ALL elements of the ...

4 years ago | 0

Answered
probability distribution from a simple vector
Note that the use of meshgrid is wildly inefficient, if all you want to know is count the frequency of one number following anot...

4 years ago | 0

Answered
How to interpolate a matrix of 1x10 into 18x1800
You can't. That is, you cannot interpolate the singleton dimension into something of size 18. As a point of comparison, suppose...

4 years ago | 0

Answered
operator '*' is not supported for operands of type 'function_handle'.
This question (or the equivalent) gets asked over and over again. I can understand where things get confusing. For example: f =...

4 years ago | 1

| accepted

Answered
Why does MATLAB (Symbolic Math Toolbox) not integrate this simple function.
Your problem is, you need to define a properly. So, if you do only this: syms x a I = int((1-x^2/a^2)^(3/2),x) Now you see th...

4 years ago | 1

Answered
How to generate a matrix with random numbers between 0 and 1 and mean of the distribution is unspecified.
You need to understand the difference between a sample mean, and the population mean. x = rand(1,100); mean(x) This is a rand...

4 years ago | 0

Answered
fmincon solution different for different start values
There are many scenarios where a solver can produce different solutions for different start values. First, know that fmincon is ...

4 years ago | 1

Answered
Spline vs Linear Interpolation
This is not remotely a question about MATLAB. I'll answer it only because I have some time, and because I do understand interpol...

4 years ago | 3

| accepted

Answered
Quadratic spline having shape preserving property
You cannot define a shape preserving quadratic spline that is differentiable across the breaks. So while you think you want it,...

4 years ago | 0

| accepted

Answered
How to optimize the solution of one optimization function using another?
Why do you think this has any remote reason to converge? Consider this trivial example of a pair of problems, based exactly on t...

4 years ago | 0

Load more