Quantcast
Channel: MATLAB programming & numeric computing platform
Viewing all 31104 articles
Browse latest View live

How the h*ck do I differentiate a function?

$
0
0

I am trying to differentiate the function "f = sin(2 * pi * x)" wrt x. When I try using "diff(sin(2 * pi * x),x)" I get an undefined variable x error. So then I do some research and turns out you have to use syms x beforehand. However, this results in a purely symbolic answer of "2 * pi * cos(2 * pi * x)" when I want a decimal equivalent. I tried converting to double using "double(f)" but that just gives me errors.

Is there not an easy way to differentiate in this program? So frustrating haha...

My Code: http://imgur.com/MmWHYFh

submitted by /u/GhostofBlackSanta
[link] [comments]

Help Using the Streamline() Function Please!

$
0
0

I've posted this question to stackoverflow a few days ago but got no response, hopefully someone here can help!

I created a vector field using the quiver function quiver(x,y,u,v) where:

x = column vector of x points

y = column vector of y points

u = column vector consisting of x component of vector at the corresponding (x,y)

v = column vector consisting of y component of vector at the corresponding (x,y) I get the following result:

https://i.stack.imgur.com/W6EgV.png

Now what I'd really like is a streamline, starting at one of the inner most points of the circle to see a path that leads to the outside of the circle. Thus I've been trying to use the streamline function as the following:

streamline(x,y,u,v,starting x, starting y)

Where x,y,u,v are all the same as used in the quiver function and starting x and starting y is just a (x,y) point.

The error I'm getting is

Error using stream2 (line 47) U,V must all be size 2x2 or greater.

But I'm not sure why u and v must have at least 2 columns?

I haven't found much documentation or examples on using streamline like this so any insight as to what I'm doing wrong and what I should do fix it would really be appreciated!

submitted by /u/PleaseHelpwithCode
[link] [comments]

Using Simulink compiled library in C++ program

$
0
0

Hello,

I have a basic control system setup in Simulink, I'd to use it in a C++ application I am building. Is this something I could achieve by compiling my Simulink model?

Thanks, Bb

submitted by /u/Bb415bm
[link] [comments]

Generate avi from series of matrices

$
0
0

I have a set of ~ 50 matrices consolidated into a 3d matrix. I(x-axis, y-axis, time) encodes for brightness. (Single channel) All values are between 0 and 1. How do I turn this into an avi movie? (specifically 5 second movie) I tried all the examples in mathworks but I cant seem to save it. I can do

for a = 1:50 imshow( I(:,:,a), [0,1] ); F(a) = getframe; end 

but I rather not plot anything and get the avi file directly.

submitted by /u/silverbluep
[link] [comments]

[Question] How can I plot this problem?

$
0
0

For my first semester matlab class, I'm trying to plot and show the traveling salesman problem. Something that looks like this https://youtu.be/SC5CX8drAtU?t=111 . What would be the best way to do this? We haven't learned much about graphing but it doesn't seem possible to do this with standard plotting. I want to have an algorithm that brute forces the possibilities until it does all the possibilities or it finds the most efficient route.

submitted by /u/bongdong42O
[link] [comments]

Plot on Image

Spit balling some ideas, not sure how to execute

$
0
0

I'm in a MatLab class and we have been given a final project. I'll include what we have learned as I'm sure our level of comprehension will help. We have covered element by element, two by two, turned those into a function, then into a looping function. We have also covered directional cosines, angles between lines, areas of geometric figures, lines normal to planes, matrix multiplication with error proofing, ifs and elses, switches, flow circuts, and vectors in 3D.

The final project has the wide parameters that are as follows, mostly verbatim from the print out:

It is best to make a model of something physical and realistic, but games and puzzles are also good.
May use MatLab and Excel.

So it's not super specific. We are considering possibly a model of a rainbow but not sure where to start on it. I'm especially uncertain about how to get the colors in the right order because all I've seen MatLab do so far is randomize the colors to its own liking.

Any input or advice would be super appreciated. TIA

submitted by /u/fknanna
[link] [comments]

Store data in a separate variable


Partial differential of a Matrix

$
0
0

I have a 6x7 matrix, say J. It is made of variables q1, q2...q7. I need to calculate the partial differential of this one at a time, ie, del J/del q1; then del J/del q2 and so on. If I use the diff Matlab function, I get a 1x42 matrix which is incorrect. It should have been a 6x7 matrix as math suggests. What am I doing wrong? Please Help!

submitted by /u/Doc_Felicia
[link] [comments]

conversion into cell array

$
0
0

i have data some thing like this ch=(1:1:15360)

i want to convert it into cell array by using mat2cell , such that each cell consist of 15360/12 data

submitted by /u/Engr_TAC
[link] [comments]

Matlab serial communications function problem

$
0
0

Hi FTP on the subreddit here. Right now I'm doing a code that will send MatLab data from my computer to an Arduino, which will execute some other code. Right now, I'm not sure whether the code is executing properly because one of the later lines (the one with mbox) which is supposed to confirm the code being executed properly by creating a pop-up box, is not occurring. We already know that the mbox function is not the problem. What is the problem? (Also, GaussianSimulatorEMG is another function that we call in matlab. I don't suspect this to be the problem, but hey! I'm probably wrong.)

function [s, flag] = steupSerial(comPort) flag = 1; s= serial(comPort); set(s, 'DataBits', 8); set(s, 'StopBits', 1); set(s, 'BaudRate', 9600); set(s, 'Parity', 'none'); fopen(s); a = GaussianSimulatorEMG(2000,1,20); while (a ~= 100) a = fread(s,1,'uchar'); end if (a==100) disp('serial read'); end fprintf(s, '%d', 100); mbox = msgbox('Serial Communication setup.'); uiwait(mbox); fscanf(s,'%u') end 
submitted by /u/generic_username_404
[link] [comments]

[Question] Does anyone know how to examine the impact of frequency and phase off set for an image ?

Trees in dialog boxes? (Possibly plots??)

$
0
0

Hey guys, just recently joined Reddit (officially, I've been surfing it for a while) and thought maybe I could get some help on a project I'm doing. Basically I'm doing a genealogy tree and for whatever reason my teacher only lets us use one display method (command window, dialog boxes, GUI's). It's come to my attention that GUI is the way to go however I have absolutely no idea how to code that (my teachers ass and hardly taught or guided us for shit). That being said my code is in process and I've been sticking to dialog boxes, however the actual tree view of the family tree isn't something I have any idea how to do. Any insights?

Tldr; having trouble figuring out way to make family tree on matlab using only dialog boxes as display methods.

submitted by /u/sapa_inca_pat
[link] [comments]

Sending variables to Matlab from Twincat 3, doing simple calculation, send back to Twincat 3 in real-time possible?

$
0
0

For a project we need to be able to calculate difference in heat between 2 points in a loop. We have Multicals 602 (Calorimeters) but they are slow as shit and can only give the heat every 7 seconds.

But we have the temperature and flow, so we could send those over to matlab and calculate the heat and then send back to twincat? Is there a way to do this?

submitted by /u/OystersClamsCuckolds
[link] [comments]

Straight line through a zigzagging 3d line

$
0
0

I have a plot of an object with an X and Y coordinate in time (Z). This plot is very zigzaggy, because 1 or 2 pixel position changes will be plotted as well. I want a simpler line, because I use the angle between the coordinates to do calculations and these angles are messing with my data. What would be a good approach to generate such a line?

Edit: my plot looks like this. I want this line to be more 'straight', as I use the angles between the individual points in the line. You can imagine the angle differences are radically different between the points later in time, but these radical changes do not mean a lot as there is very little movement.

submitted by /u/Revules
[link] [comments]

Trying to follow following example

$
0
0

Hi Guys,

i am following this example: Matlab Example

I have Matlab r2014b

When I type:

filePath = fullfile(fileparts(which('PathPlanningExample')),'data','exampleMaps.mat'); load(filePath) 

I get following error:

Error using load Unable to read file 'data\exampleMaps.mat'. No such file or directory. 

What am I doing wrong? I just wanna build grid like that

submitted by /u/k31453
[link] [comments]

How to write function(?) where input involves multiple matrices and incorporates them into a single matrix as the output?

$
0
0

Hello all, I am extremely new to Matlab (I have some experience with R but have been tasked with a project that Matlab seems to be better suited for), so I would really appreciate if someone could point me in the right direction. Let me know if this is the wrong sub for this. Sorry for making it sound like a silly puzzle. The actual project involves species data with ~600 data points but I'm trying to figure out how to deal with an analogous simplified version so that I can learn the basics behind it first and make sure it is correct.

Data/input:

I have an excel file with multiple sheets. Each sheet is one sample. In each sheet, the first column has nominal categorical data (species), followed by multiple columns of numerical data, of which the only relevant column is (amount); the amount is the number of each species present in each sample. The species data differs quantitatively and qualitatively in every sample; for instance, sample 1 could have dog (amt=9) and cat (amt=8), while sample 2 has dog (amt=7), fish (amt=6), and turtle (amt=5), and sample 3 has cat (amt=4), turtle (amt=3), penguin (amt=2), and dragon (amt=1).

Analysis/output:

I want to write a function that extracts species and amount data from an excel file with multiple sheets to construct a matrix in which each row (i?) corresponds to each unique species (order doesn't matter, but no doubles) and each column (j?) corresponds to each sample, and the value for each element in the matrix is either 0 (if the species is not present in that sample) or n (where n=amt of that species in that sample).

Larger goal:

This seems like a fairly simple problem since it is simple (although tedious) to do by hand in excel. However, in dealing with larger data sets (of more than 1000 species), it would be much more efficient/reasonable to have an automated program or function that I can just apply to a whole excel file and have it run through and return the matrix so the real data visualization and analysis can be done sans brute force prep work.

I would really appreciate for someone to point me in the right direction of how to do something like this. Part of the problem is that it requires mixing quantitative and qualitative data which causes problems. Sorry the question is a bit vague, I don't have much experience and just getting started is turning out to be a bit of a roadblock. Thanks so much in advance

submitted by /u/higgshmozon
[link] [comments]

[QUESTION]Physics related matlab projects?

$
0
0

I can't think of a physics related matlab project for my computational physics course. The project must be related to waves, optics and thermodynamics. This is a final project and I can't think of anything advanced enough to be an acceptable final project or anything simple enough that I can do it within two weeks.

submitted by /u/jack-tor
[link] [comments]

Matlab GUI help

$
0
0

Hey guys, I am having some issues with matlab gui. I am trying to create a GUI that creates a graph when you press different buttons and then using two sliders, you can trace the graph and get some data. I have the buttons working to plot the graph on the axes. I need help trying to plot the slider tracer on the graph and to get it to work.

submitted by /u/tm12567
[link] [comments]

(X-Post from r/askengineers) How to set up Optimizer/MATLAB interface for GMAT?

$
0
0

Hi guys, I'm a 3rd year aerospace engineering student working with NASA GMAT for my dissertation. I've attempted to build the VF13AD optimizer first as I didn't have access to GMAT, but ran into issues creating the header files (I wasn't sure which function calls to copy) I've now attempted to go down the MATLAB route now but despite following the data configuration guide and other setup on the GMAT site Im still getting the error : *** Unable to load the dynamic library "..\plugins\libPythonInterface" *** Error loading "libMatlabInterface": GMAT could not load the MATLAB interface. Please check that MATLAB is installed and configured correctly. See the User Guide for instructions, or disable the appropriate PLUGIN line in bin/gmat_startup_file.txt to remove this errors: * libMatlabInterface could not load or is disabled, or the MATLAB Optimization Toolbox is not available. Disable the appropriate PLUGIN line in bin/gmat_startup_file.txt to remove this error. Would anyone be able to walk me through setting one of these up (Deadline is fast approaching) or answer some questions. I can provide more specifics if needed. Thanks guys

submitted by /u/AdventurousTurtle
[link] [comments]
Viewing all 31104 articles
Browse latest View live