Questions tagged [matlab]

Programming questions about MATLAB are off topic and should be asked on Stack Overflow. MATLAB is a high-level language and interactive programming environment developed by MathWorks. It is the foundation for a number of other tools, including Simulink and various toolboxes that extend the core capabilities.

Filter by
Sorted by
Tagged with
1 vote
0 answers
130 views

MATLAB GPU-enabled function? [closed]

Is there a way for me to find out whether the functions I'm using in a MATLAB script are GPU-enabled? There does not seem to be a comprehensive list (though see this link for a list of image ...
user221772's user avatar
1 vote
1 answer
434 views

How to remove the bland space to the left of ylabel in Matlab figure when using long string for ylabel?

I'm doing some plots in Matlab 2014b, in one them I'm plotting 5 variables versus time over there and want to specify 5 names like, speed (rad/sec), voltage (V), ... etc. on the y-label, however, as ...
AlFagera's user avatar
  • 195
1 vote
2 answers
2k views

To draw x-axis and y-axis, both through origin (MATLAB)

In the following MATLAB plot, I want to draw x-axis and y-axis, both through origin. What would be the easiest code? x = linspace(-2*pi,2*pi,100); y1 = sin(x); y2 = cos(x); figure plot(x,y1,x,y2)
user1942348's user avatar
1 vote
0 answers
513 views

How to plot an ellipsoid in MATLAB knowing eigenvalues and eigenvectors?

Using [V,D]=eig(Pmatrix) I get V= 0.7107 0.6581 -0.2486 -0.6849 0.7280 -0.0306 -0.1608 -0.1920 -0.9681 D= 103.2955 0 0 0 127.9054 0 0 ...
Armadillo's user avatar
  • 133
1 vote
1 answer
218 views

Matlab ploting in one figure from function

I wrote a function that plot a function y(t) using 4 input argument. function plot_me_n1(A,B,m1,m2) t = linspace(0,10,10/0.01); y=A*exp(-m1*t) - B*exp(-m2*t); plot(t,y,'color',rand(1,4)); title('...
ZeroVash's user avatar
  • 111
0 votes
1 answer
235 views

Making windows have better names

When I'm programming in Matlab, the scripts that I write all have the directory as part of their name, resulting in it being impossible for me to distinguish them by their names. Here's a picture to ...
Steven Sagona's user avatar
-1 votes
1 answer
75 views

Matlab: Get graphics object's name

Some (graphics) objects in Matlab seem to have "names". For example, if I create a plot plot(1,1) and give it a title title('mytitle') and then access the current axes via gca I get the following ...
Wauzl's user avatar
  • 761
1 vote
1 answer
191 views

When ploting 3d scalar field with Matlab, why axis X exchanges with Y?

When I draw the isosurface of a 3d scalar field A(i,j,k) (i=1~31, j=1~151, k=1~151) using Matlab, in the figure, indice j corresponds to X axis, i corresponds to Y axis. How does Matlab arrange 3d ...
user avatar
3 votes
1 answer
340 views

What is the Excel equivalent of Matlab's randn function

The randn function of Matlab generates a random number from the standard normal distribution. What is the equivalent in Excel? I think the rand(2)-1 is not the right solution because the random ...
ZZZ's user avatar
  • 131
1 vote
1 answer
650 views

One-liner to sort STRUCT in MATLAB?

Seeking a one-liner MATLAB function / command to sort by date the output of: filenames = dir(filenameSubstring); % retruns struct sortrows() is for matrices and seems to rely on the sorting column ...
gatorback's user avatar
  • 1,225
0 votes
1 answer
2k views

Matlab/Octave Solving Matrix Using Gauss Seidel not Converging

Something totally impossible is happening. I have run the following code multiple times on the same Matrix and always converged to a solution using the Gauss Seidel method within 10 iterations. My ...
Dean P's user avatar
  • 117
0 votes
0 answers
182 views

Thermistor to Celsius/Fahrenheit/Kelvin in MATLAB

Thermistor to a Temperature Unit in MATLAB I am using an Analog Read Pin on an Arduino Uno to read the temperature as given by a thermistor. The resistor being used on the thermistor is 220𝝮. What I ...
Noah Wilder's user avatar
0 votes
1 answer
43 views

Export all MATLAB images in one go

Code: https://pastebin.com/6MWsmaJF Essentially, I've created a function in Matlab which spits out around 200 images. How do I save all of these images in one go?
Jeremy Feng's user avatar
0 votes
0 answers
169 views

Matlab R2016a on Ubuntu 14.04 and JDK 1.7; Needed? Alternatives?

I have already successfully installed Matlab 2016a on Ubuntu 14.04. As the installer finished wrapping up, it notified me that I was missing some necessary compilers. I noticed that I had forgotten to ...
MechanicalMan's user avatar
-1 votes
1 answer
263 views

Stacked Bar Graph in Excel or Matlab

I want to represent this graph either in matlab/excel . X-axis show the load on primary network with values ranging 0.0 to 0.9 At Y-axis there is a ratio of NSU/NCH that goes from 0.08 to 0.44 each ...
Atif Shakeel's user avatar
0 votes
1 answer
116 views

How can the colors of ones choice be added to the legends manually in an image in MATLAB?

I wish to add the colors to the legends as per the rgb values of the corresponding color in the image. The image can be displayed using the code written below: x1=ones(30); x2=2*ones(30); x3=3*ones(...
Shivam Pande's user avatar
1 vote
1 answer
126 views

Matlab fprintf function does not create newlines

I tried to remove some lines from a file using following commands. fData = textread('s0001_rem.hea', '%s','delimiter','\n','whitespace', ''); fData ([20 19 18])=[]; fid=fopen('s0001_rem.hea', 'w'); ...
Samitha Nanayakkara's user avatar
1 vote
1 answer
131 views

MatLab: Line break between arguments of a function

When writing a function with arguments in MatLab, can the arguments be separated by a line break in some way (similar to separation by whitespace characters such as space or tab being allowed)? An ...
Steeven's user avatar
  • 283
0 votes
1 answer
111 views

Colon-generated arrays with or without brackets in Matlab

From what I can tell, the arrays a:d:b and [a:d:b] are exactly the same thing. For example, >> [1:3] == 1:3 ans = 1×3 logical array 1 1 1 Yet, these two expressions give different ...
optical's user avatar
  • 123
0 votes
1 answer
2k views

Matlab Hardware OpenGL Failure on Ubuntu 16.04.3 - Can not initialize shared resources

First, my system info: 4.13.0-26-generic #29~16.04.2-Ubuntu SMP Tue Jan 9 22:00:44 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux Clean installation of Matlab R2016b (64-bit) Video card: AMD/ATI Pitcairn ...
AndrewCox's user avatar
  • 161
1 vote
1 answer
61 views

Storing the plots in a folder while running the MATLAB program?

In my MATLAB program I have to run a for loop for 500 times and each time the loop runs it plots a graph, so If I run the program there will be 500 (.fig files) and that may hang my system. So is ...
BAYMAX's user avatar
  • 125
0 votes
1 answer
251 views

Matlab, fimplicit, how to show a specified region on graph using an inequality

I am using fimplicit command to produce a graph, but i have a condition x+y<=1, and I want only that region of the graph to be shown. Example: f = @(x,y) x.^2 + y.^2 - 3; fimplicit(f,[-3 3 -2 2]) ...
ahmetdoe's user avatar
1 vote
0 answers
31 views

matlab symbolic equality wrong

Why does matlab return a zero instead of a 1 for this command isequal(3*sin(x1)*M+3*sin(x1)*m,3*sin(x1)*(M+m)) similarly it returns a zero if I do isequal(3*sin(x1)*M+3*sin(x1)*m,simplify(3*sin(x1)...
Thomas Kirven's user avatar
0 votes
1 answer
465 views

MATLAB Figure as Windows Enhanced Metafile Issues

I am having an issue with a figure I have been trying to create in MATLAB. Let me provide you with some reference and background before going into the details. I am in the process of finishing up a ...
Nukesub's user avatar
  • 171
0 votes
0 answers
14 views

Having real trouble installing community toolbox

I can't install coco for the life of me. I am familiar with MATLAB, but I have never installed a toolbox, and that's where I'm having problems. I want to install coco. I have installed MATLAB 2012b, a ...
ConfusedSocialScientent's user avatar
0 votes
0 answers
2k views

Converting UNIX time to human time in MATLAB?

I've a sequence of UNIX timestamps in milliseconds (e.g. 1491009470000). I want to convert them to human time in the format year-month-date-hour-minute-second (or in an array of these components). ...
Mathmath's user avatar
1 vote
2 answers
153 views

Graphic in Excel of lifetime and capacity of power plants

I have data on capacity, construction date and shutdown date of different power plants. I would like to build a graph in Excel that shows at one glance these information, i.e. in sort of a shifted ...
LenaH's user avatar
  • 67
0 votes
1 answer
39 views

Evaluating symbolic fractions without assigning values to the symbolic variables in MATLAB?

I'm working with a few matrices and trying to simplify the results involving symbolic terms. The subs() command won't work because there are no values assigned to the variables. But it's nasty trying ...
Asinine's user avatar
  • 67
0 votes
1 answer
572 views

Matlab - how to put the same number of decimal places in the axes

How can I put all the axis numbers with the same number of decimal places on the chart? I want all y-axis numbers to have the same number of decimal places. Thanks.
Carmen González's user avatar
1 vote
1 answer
46 views

Weird behaviour in MATLAB regarding eval()

Consider the following code x = zeros(3,3); eval(str3) g = @(x) eval(str3) g(x) g(zeros(3,3)) MATLAB will evaluate eval(str3) as intended, but complain about the other two claiming they are ...
Markus Klyver's user avatar
0 votes
1 answer
698 views

Quick way to linearize values using given array in Matlab

I'm looking for a quick way to linearize a value between values in Matlab. Example: a = ([10 20 30 40]) index = 1.5 //a float index func(a,index); //shall return a value between index 1 and 2. In ...
Cleber Marques's user avatar
0 votes
1 answer
258 views

Sum of sinusoids (Fourier decomposition)

Does anyone know how I can recreate a plot like this using matlab? Have been browsing but can't really find much on the topic. I pretty much want to take a non-sinusoidal, but periodic waveform and ...
user avatar
0 votes
1 answer
352 views

MATLAB save all variables separately

My current workspace contains 32 variable sequentially named. Each variable is an array of doubles with different lengths. I want to save each of them as a separate .mat file such that name of each ...
samwise_the_wise's user avatar
1 vote
0 answers
52 views

An ODE with optimal control

I am trying to numerically solve an ODE of the form: rV = max(f(a)X + a V') + 1/2 sigma^2 V'' where the maximization is done over a. r and sigma are known parameters, so I'm just trying to find V(x)...
Shffl's user avatar
  • 111
0 votes
1 answer
28 views

How to create a cell values vector out of several 3D matrices

I'm currently trying to do one thing in matlab. The situation is simple: I have about 70 3-dimensional matrices of the same size (192 x 192 x 30). What I need to obtain are vectors created from values ...
Piotr Kopczyński's user avatar
0 votes
1 answer
106 views

Error when open MATLAB R2016a

I have installed MATLAB R2016a on my Ubuntu 14.04. Each time I open MATLAB, the error comes out. However, MATLAB can still work. So, how can I fix the error?
Ke Gong's user avatar
1 vote
1 answer
4k views

AltGr opens menu shortcut tooltips in Matlab

When I press Alt Gr / AltGr in Matlab, it triggers the menu bar to show the shortcut letters as tooltips on the respective buttons. This would be great if I would want to use a Alt Gr + Hotkey ...
Honeybear's user avatar
  • 193
4 votes
3 answers
26k views

How to configure GPU to work in TCC mode on Windows 10?

I'm using Windows 10, and I want my GPU to dedicate itself to computing, instead of graphics. Here is the information on MATLAB: >> gpuDevice ans = CUDADevice with properties: ...
Dang Manh Truong's user avatar
0 votes
1 answer
223 views

Calculating convolution using matlab

I want to calculate the convolution of the following equation. $$x[n] = \sin{\frac{n*\pi}{6}}(u[n] - u[n-12])$$ I got up to the following line of code: >> stem(5, y); >> plot(n, y); >...
user avatar
0 votes
2 answers
100 views

How to store output of Matlab command (like a pipe in UNIX)?

I am asking on this community per this question. Please let me know if this is incorrect and which community I should use. I am trying to evaluate an integral in Matlab using: int(x^(2)*sin(n*x),x) ...
wcarhart's user avatar
  • 153
1 vote
2 answers
4k views

How can I use MATLAB in atom?

I want to be able to run matlab scripts in atom using the script paclage. When I do so, I get the following error. MATLAB - Coins_Riddler.m:23 Unable to run matlab Did you start Atom from the ...
Demetri Pananos's user avatar
20 votes
4 answers
43k views

How to release/reset serial port FTDI devices - Mac OSX

I am trying to work with a custom PCB that uses an FTDI FT232RL to talk to my computer (MacBookPro running OSX 10.11 El Capitan) for a hardware project. I am using Matlab to send serial commands, ...
thkemp's user avatar
  • 303
0 votes
1 answer
108 views

matlab: making the domain of a function dependent on the domain of the inputs

Suppose one has functions f(i) and g(j). How could one write a function h(k), where the domain k of h is made up of all k=i+j (i.e., each point h(k) is some function of f at i and g at j for all pairs ...
user001's user avatar
  • 3,654
1 vote
0 answers
200 views

'DefaultColorbarFontSize' not working

I am trying to make this option work in a code like: AxLabMultip = 1.9; AxFontSiz = 14; set(groot, ... 'DefaultColorbarFontSize', 10000, ... % !?!?!?!?!?!?!?!?!?!?!?!? '...
Andrestand's user avatar
0 votes
0 answers
648 views

MATLAB crashing system (gentoo linux)

First let me preface this by stating that I'm pretty new to MATLAB and Linux, perhaps I'm missing something obvious, if that's the case please be patient with me. I've been asked to help with a ...
uvsvdu's user avatar
  • 1
0 votes
0 answers
80 views

What program should I use to edit a 1 GB Matlab code

I just used Matlab's Neural Network Toolbox to create some functions (.m files that return matrices based on the matrix you put in). I now need to edit the code a little, to modify some details. But ...
Post169's user avatar
  • 164
0 votes
0 answers
57 views

Two USB cams with one USB hub behave differently on two different laptops with same OS windows 10

I have been trying to access two USB cameras through a USB hub (bought from local market). I am able to access both the cameras one after the other without any issue but when I tried to access both ...
kotesh_9913's user avatar
0 votes
1 answer
36 views

matlab , working with 2 instances at once

this bug is really annoying me so i have a few scripts (costfunction.m and others .. , doing neural networks) i want to work on 2 projects at once , so i create a folder for the second project, i ...
user31731's user avatar
0 votes
0 answers
738 views

matlab takes too much ram, what's wrong?

On my win10, I have MATLAB 2016a. when I use task manager to watch the system, I found that MATLAB takes too much memory. On the other hand, mathematica use very little memory, both of them are not ...
an offer can't refuse's user avatar
0 votes
3 answers
162 views

MATLAB,Signal Processing

Is it possible to convert a PDF to .mat file for processing in MATLAB? I have ECG signal in PDF format.I want to process it in MATLAB
user avatar