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
1
vote
3 answers

How to find the intersection points of two circles in 3D

I have two circles in 3D space generated from their parametric equations. Also, these two circles are on the same plane. How can I find out their intersection points from the parametric equations? Thanks everyone, your answers are really helpful.…
96742zs
  • 65
1
vote
0 answers

How do I draw a perfect egg graph in matlab?

These are my codes: clear all; close all; %parameters c0 = 14 c1 = 6 c2 = 1 alpha = 4 %% Figure parameters % Axis bounds xmin = 0 xmax = 10 ymin = 0 ymax = 10 nmin = 0 nmax = 10 tmin = 0 tmax = 10 %Vector of n values n = linspace(nmin, nmax,…
OGC
  • 2,305
1
vote
0 answers

Plotting a set in MATLAB

I am trying to plot sets like $$\left\{x \in \mathbb R ^3 : x_1,x_2,x_3 \geq 0, x_i \leq x_j + x_k \mbox{for all combinations of }i,j,k \in \{1,2,3\} \right\}$$ with MATLAB to include the figures in a document I am writing and I could not find a…
jan1892
  • 142
1
vote
1 answer

Matlab, how to know time step size in the plot or how can I get the output of time step size?

Since I am using matlab ode23s solver, it contains two matlab files. One contains the differential equations and another contains plotting and to run the m-files. The code are working perfectly. Now I want to know the time step size that is using on…
1
vote
3 answers

How to define a piecewise function in matlab?

I want to calculate the convolution sum of the continuous unit pulse with itself, but I don't know how I can define this function $$ \delta(t) = \begin{cases} 1, 0 \le t \lt 1 \\ 0, otherwise \end{cases}$$ in Matlab.
1
vote
0 answers

Drawing root locus diagram using Matlab

I am having some problems (or so do i think) making matlab draw a root locus diagram of closed loop system. I have this close loop transfer function $T(S) = \frac{\frac{K_p}{s(s+1)} + \frac{K_iS}{s(s+1)} +…
1
vote
1 answer

Max command MATLAB

My friends and I have been trying to resolve a localized problem in MATLAB code - It deals with the "max" command - we are trying to find the maximum of R01 and R02, and plot this max against varying values of gamma1. The problem is in the for…
user85362
1
vote
1 answer

Two outputs in matlab function

I'm calling a function with 2 outputs: 2 vectors of different size. I need to use 2 vector of different size (outside of the function) that are calculate inside of the function. How can I use both vectors out of that function? Thanks
yemino
  • 814
1
vote
1 answer

Question about a matlab matrix

To explain my problem I goint to show a little example. I have a matrix K $K=\begin{pmatrix}k_{11}&k_{12}&k_{13}\\ k_{21}&k_{22}&k_{23}\\ k_{31}&k_{32}&k_{33}\end{pmatrix}\in\mathbb{R}^{3\times 3}$ and a big matrix $A$, for example $A\in…
yemino
  • 814
1
vote
2 answers

Solving system of equation with many variables and parameters

I wonder if there is any way how to made MATLAB solve the system of equation as this: $ s\cdot x_1 = \frac {R_1L_2}{M^2-L_1L_2} x_1+ \frac {MR_2}{M^2-L_1L_2} x_2+\frac {M}{M^2-L_1L_2} x_3 - \frac {L_2}{M^2-L_1L_2} u +…
user50222
  • 978
1
vote
1 answer

Recursive function for $a^n$ in matlab

A recursive definition of an where a is an integer and n is a non-negative integer follows: a^nif=1 if n = 0 a^n=a*a^(n-1) if n>0 Write a recursive function called mypower, which receives a and n and returns the value of an by implementing the…
joke
  • 41
1
vote
3 answers

How to write this efficiently in MATLAB?

I would like to re-write this efficiently in MATLAB. n=3; x=zeros(n); y=x; for 1=1:n x(:,i)=i; y(i,:)=i; end I tried to run it in MATLAB and get this output below x = 1 0 0 1 0 0 1 0 0 y = 1 1 1 0 0 0 …
joke
  • 41
1
vote
2 answers

help on matlab code

I would like to display errors in case a user enters a number less or equal to 0.how can i put it? thanks Problem:Write a script areaMenu that will print a list consisting of “cylinder”, “circle”, and “rectangle”. It prompts the user to choose one,…
joke
  • 41
1
vote
0 answers

Using Lambertw to solve $x\ln(x) = a$

I am trying to solve the equation $$ x \ln (x) = a, $$ where $x$ is a variable and $a$ is a given constant, using Matlab and the lambertw function. Not really sure exactly what to type into Matlab to solve this equation! Thanks in advance for any…
Kylar
  • 11
1
vote
2 answers

Generating a triangular matrix on MatLab with loops

I am trying to create a triangular matrix from a row vector using loops. I know there are built-in commands that makes this easy, but I am a beginner programmer and I want to test this out. Here is what I've got so far. function [ a ] = Up( v ) n =…
Lemon
  • 12,664