Answered
How to write log base e in MATLAB?
The log function does exactly what you want. log(14 - y) If you want a base 10 log, you use log10. There is also a log2 functi...

7 years ago | 3

| accepted

Answered
Precision in calculation of large digits
What you need to understand is how MATLAB works. When you have one function call another, it evaluates the inside operation FIRS...

7 years ago | 3

Answered
Multiplying every secound element in a vector with -1
You need to start learning MATLAB. That is, actually learn to use vectors, matrices, not just work with single numbers, and loop...

7 years ago | 1

| accepted

Answered
Surf plots 2D + color. I want a 3D plot. What is the solution?
But what you have, that is z(x,y), is a 2-dimensional manifold in R^3, that is, a surface embedded in the 3-dimensional cartesia...

7 years ago | 1

| accepted

Answered
How to use interp1 to stretch out smaller vector to the size of larger vector?
Assuming that you intend to create a vector of averages, do this: Ahat = interp1(1:1260,A,linspace(1,1260,1778)); C = (Ahat ...

7 years ago | 3

| accepted

Answered
Collecting terms / factoring out multiplied terms
Be serious. That is not big. There are some things (this is one of them) that are far simpler to do by pencil and paper than to ...

7 years ago | 0

Answered
Less time consuming substitution for if conditional
I think you are focusing on the wrong things. This is NOT a slow operation. Very likely, this is part of a large, inefficiently...

7 years ago | 0

Answered
How do I do this function?
x = -1:0.1:1; f = x.^2.*sin(pi.*x); g = max(0,f);

7 years ago | 0

Answered
How can I fit data to a sine curve?
I'll guess the model you want is as below, but use the curve fitting toolbox. Your model might be defined as: ft = fittype('si...

7 years ago | 0

Answered
How to implement an equality and inequality constraint
You said both an equality AND an inequality constraint in the subject. But then you showed only the inequality. The inequality ...

7 years ago | 0

| accepted

Answered
How do you get the equations of shape-preserving fitting method automatically?
The problem that Matt is getting at is, the equation of a set of points as fit by any spline (including shape preserving interpo...

7 years ago | 2

| accepted

Answered
Why do I keep getting the error message array indices must be positive integers or logical values?
MATLAB has an index origin of 1, not 0. So X(0) will fail, and give you exactly that error. (Matt pointed that out.) But also ...

7 years ago | 0

Answered
How do I solve this system of equations for real number?
Whats the problem? There appear to be six real solutions. Solve finds them with no problem. xyz = solve(eqn1,eqn2,eqn3) xyz = ...

7 years ago | 0

Answered
Fitting a natural log curve
Um, a log curve does not have that shape. (Natural or not.) So trying to use a log function to fit that data will not leave you ...

7 years ago | 0

Answered
Two dimensional interpolation polynomial
I don't think you realize that an interpolation polynomial that passes exctly through 300321 points will be impossible to evalua...

7 years ago | 0

Answered
Create an ellipse with equal distance between two points
The simplest way to do this is to use my interparc tool. Just take the set of points on the ellipse. Then pass them into interp...

7 years ago | 2

| accepted

Answered
Plot is a straight line when it should be a curve.
Is it really a straight line? Seriously? Did you look CAREFULLY at the curve? A PERFECTLY STRAIGHT LINE? (No.) I'll admit that t...

7 years ago | 1

Answered
Generating sequences from data
So, given a vector x, of length n, you want to create the array with rows that are the sub-sequences of length 5? The result wil...

7 years ago | 1

Answered
Integral of a surface bounded by 2 hyperbolas
This is not a problem that MATLAB cannot handle something. It is a problem of using the wrong tool. Integrate is a curve fittin...

7 years ago | 0

| accepted

Answered
Weird numerical integration behavior
No. You should NOT make it inf. Even 1e24 is incredibly large, wild overkill. As to why you are using integral to compute the a...

7 years ago | 0

| accepted

Answered
How to optimise this equation?
Must n be an integer? After all, you have factorial(n-1) in there. If it must be an integer then just test a list of integer val...

7 years ago | 0

Answered
how to create a vector of equations in matlab
No. There will be no trivial way to magically enter those equations, and have MATLAB know how to evaluate things. In fact, it is...

7 years ago | 0

Answered
next prime number using While loops
There have now been multiple answers to this homework, all of which are fairly equivalent. (The response by Shubham Sangle has a...

7 years ago | 9

| accepted

Answered
the runtime (computational complexity) of perms function?
You are mistaking the problem here. The issue will always be allocating sufficient memory, thus, the memory required will be wha...

7 years ago | 2

Answered
How to make a nxm Vandermonde matrix?
A = x(:).^(2:-1:0); That works as long as you are using MATLAB R2016b or later. Earlier releases would need to use bsxfun, or e...

7 years ago | 1

| accepted

Answered
If we have non-linear constraint can we use "quadprog"
No. Quadprog is only able to accept LINEAR constraints. (equality, inequality, as well as bound constraints on the parameters. B...

7 years ago | 0

| accepted

Answered
Parallel Processing for Simple Code
Um, so? You clearly are not an experienced user of MATLAB. So your code may be inefficient. That it took a long time is not a su...

7 years ago | 1

| accepted

Answered
Linprog error "-96@30"?
You are trying to solve the problem of minimizing 3*x + 3.4*y subject to the constraint 3*x + 4*y <= 20000 with bound...

7 years ago | 0

| accepted

Answered
Find minimum of an n variable function, n is like 800+
In theory, of course it is possible. Maybe not even that difficult. In practice, there are always issues that involve the skill ...

7 years ago | 1

Answered
I am trying to solve for an integral using the relation y(n)=ny(n-1)-(1/e) and that y(1)=1-(2/e). Below is my function but I am not sure what to do about the 'y(n-1)' part.
First, you might recognize that 1/e = 1/exp(1) = exp(-1). So if you are going to compute an exponential, thus exp(1), then why ...

7 years ago | 0

| accepted

Load more