Questions tagged [matlab]

For mathematical questions about MATLAB; questions purely about the language, syntax, or runtime errors would likely be better received on Stack Overflow. MATLAB is a high-level language and interactive programming environment for numerical computation and visualization developed by MathWorks.

MATLAB (Matrix Laboratory) is a high-level language and interactive programming environment for numerical computation and visualization developed by MathWorks. MATLAB can be used when performing tasks such as signal processing and communications, image and video processing, computational finance, and computational biology. It is the foundation for a number of other tools, including Simulink and various toolboxes that extend its core capabilities.

In addition, MATLAB is a proprietary product of MathWorks. This means that, unlike other GNU GPL open source languages, both programmers and users must own a valid software license for running MATLAB code. There are several open source alternatives to MATLAB, in particular GNU Octave, which offers bidirectional syntactic compatibility with MATLAB, Scilab, SciPy, and Julia.

You could think about posting your question on Stack Overflow. They've got plenty of questions/answers already there.

Some informative links that show up quite often in answers:

User Amro has created a user-script for Matlab Syntax Highlighting for Stack Overflow. Use this link to install it.

3165 questions
0
votes
0 answers

Solving Linear Program involving Matrix Variables

I am using Matlab to solve a Linear program which involves 3 dimensional matrices with entries X(a,b,c). Each Linear inequality/equalities involves multiple pages of the matrix X. I can always convert X into a vector, and modify the objective…
0
votes
1 answer

Define a function that is a product of two previously defined functions

New to matlab and having difficulty with the syntax since im used to using mathematica. In mathematica i can define two functions $f(x)=x$ and $g(x)=x^2$ and define a third function simply as $h(x)=f(x)g(x)$ where f(x) and g(x). How do i do the same…
anonymous
  • 401
0
votes
1 answer

Find the number of times each element in a vector is repeated, using MATLAB

Consider a vector in MATLAB, where some elements are repeated. For example $$v=[1 , 2, 7 , 8 ,3 ,2 ,8].$$ How can I find how many times each element in this vector is repeated without using a loop. Is there any MATLAB command for this?
Rosa
  • 1,502
0
votes
1 answer

Control system on matlab

A satellite is launched for an astronomical mission, for which it needs to points its scientific sensor package in a specific direction. A simplified linearzed mathematical model of the above satellite is given…
richa
  • 1
0
votes
1 answer

Matlab: function gradient and Hessian in the same function

Implement a Matlab function for computation of $ f(x),\nabla f(x),\nabla^2 f(x) $ The function must have the interface: function [f,df,d2f] = FunEx1(x) where $f(x)=f=x^2-2x+3xy+4y^3;$ I tried: function [f,df,d2f] =…
0
votes
1 answer

Use Matlab to determine the point of intersection of lines

I want to determine the point of intersection of two lines using Matlab. I have the two lines in the form of y = tan(theta)*x + c. I'm seeking an algorithm that does this and I already know how linear equations are solved manually to determine the…
0
votes
1 answer

Matlab 'For' loop and line plotting [Beginners question]

function question2a(a,x) y=zeros(1000,1); y(1)=x; hold on; for j=2:1000 y(j) = a*y(j-1)*exp(-y(j-1)); plot(j, y); end hold off; end Is my code for a certain exercise, however I am not getting a line instead of a line I am…
Gauss
  • 41
0
votes
1 answer

Solving Quadratic on Matlab (slightly more complex)

I am new to this site so I apologize if this post doesn't belong here or anything. I am trying to solve a quadratic on Matlab. This is relating to my electrical engineering circuits course where I have to determine the drain current. All the values…
tam
0
votes
1 answer

Help plotting a polynomial in MATLAB.

This time I want to plot he interpolation polynomial with the coefficients given by the following code: %Code for the polynimial interpolation. %We first define the points where we want that our polynimial…
user162343
  • 3,245
0
votes
1 answer

Plotting a graph in MATLAB with $y$-axis data varies over order from $10^0$ to $10^{-1009}$

I want to plot a graph in MATLAB with $x$- axis data varies from $1$ to $15$, where as $y$-axis data varies over order from $10^0$ to $10^{-1009}$. Using 'semilog' or 'set axis I am not able to plot graph for $y$-axis data having order lower that…
Srijan
  • 12,518
  • 10
  • 73
  • 115
0
votes
1 answer

Help using Secant method in Matlab

So here is the funciton that I created: function S = Secant(po,p1) f = @(x) -x^3-cos(x); tol = 10^-7; n=1; p=[]; p(n-1)=po; p(n-2)=p1; n=n+1; p(n)=p(n-1)-f(p(n-1).*(p(n-1)-p(n-2)))/f(p(n-1)-f(p(n-2))); while abs(f(p(n)))>tol &&…
mathpls
  • 15
0
votes
1 answer

Finding a contraction.

I want to find a function $g$ such that it is a contraction and such that finding its fixed point is the same as finding the zeros of $f(x)=x^3+x-3$ because I have implemented the fixed-point iteration method in MATLAB as follows function…
user162343
  • 3,245
0
votes
0 answers

Secant method performed wrong.

I have perfomed the MATLAB method in MATLAB as follows: %Implementation of the secant method. function c = secant2(x0, x1,eps) format long e fx0 = f(x0); fx1 = f(x1); if abs(fx1) < abs(fx0), %c is the…
user162343
  • 3,245
0
votes
1 answer

Matlab: Generating Data using a cubic equation with a specific variance

I'm wondering if it's possible to generate data (d) in Matlab using the equation $$ d = 1 + 0.5z + 0.25z^2 + 0.125z^3 $$ where $$ 0 < z < 1 $$ and the variance is $$ \sigma^2 = 0.01 $$ I've generated guassian random variables with a defined…
user1707828
  • 143
  • 5
0
votes
1 answer

Please help me understand the ode45 usage

I'm studying numerical analysis and the answer for this problem (the question is in English) that is solved with the following code: p1 = -20.2090; p2 = 17.3368; p3 = 272.9057; beta = 7.8*pi/180; x0 = 2000; c =…