matlab

Variance in random Walk with Matlab

落花浮王杯 提交于 2021-02-11 12:55:51
问题 I'm new to the forum and a beginner in programming. I have the task to program a random walk in Matlab (1D or 2D) with a variance that I can adjust. I found the code for the random walk, but I'm really confused where to put the variance. I thought that the random walk always has the same variance (= t ) so maybe I'm just lost in the math. How do I control the variance? 回答1: For a simple random walk, consider using the Normal distribution with mean 0 (also called 'drift') and a non-zero

Is it possible to use mldivide “\” on a 3D matrix in Matlab

旧时模样 提交于 2021-02-11 12:54:48
问题 Is it possible to use mldivide ( \ ) on a 3D matrix in MATLAB? I would like to avoid using a for loop? Sample: A = rand(4, 100, 5); B = rand(4,4); I need to perform: C = B\A; What I'm doing now: Apply the mldivide on a for loop for each "slice" i: for i = 1:size(A, 3) C(:,:,i) = B \ A(:,:,i); end 回答1: You can reshape A into a 2D matrix to perform the division and then back to the expected size afterwards. The reshape operations should be relatively quick due to the fact that MATLAB doesn't

Running a cmd file without GUI popping up

断了今生、忘了曾经 提交于 2021-02-11 12:38:24
问题 I'm running a list of commands in a file: matlab -nodesktop -nodisplay -nojvm -nosplash ............. xwin32 --session .................... I would like to have them run without the GUI popping up in Windows and more of all I would like the command prompt GUI not to pop up, anyone have any idea how to do it? tnx 回答1: Best you can do on Windows is: batchScript.cmd start /B /MIN matlab.exe -nodesktop -noFigureWindows -nosplash ^ -r "surf(peaks); saveas(gcf, 'output.eps'); quit;" You can add the

Chocolatey generated VS 2015 Compiler not found on docker image

天涯浪子 提交于 2021-02-11 12:34:04
问题 I tried to install visual studio 2015 build tools on a Docker Container using the chocolatey packet manager. I need it for a Matlab code gen build operation. The chocolatey steps works fine. But my docker container can't find the compiler. Any Hints? Docker RUN powershell -command choco install -y vcredist140 RUN powershell -command choco install -y vcbuildtools -ia "/Full" Using mex -v -setup I have: Host(WIN10): ... Looking for compiler 'Microsoft Visual C++ 2015 (C)' ... ... Looking for

Use a slider in MATLAB GUI

南楼画角 提交于 2021-02-11 12:15:27
问题 Really simple question. I wish to create GUI with a simple plot that changes something with a slider. I have been using the GUI and have a slider+text on a panel and axies1. So for starters I just wish to have the slider going from 1:10 (no specific increments) and scaling the y-values (by 1:10). I have imported my data into the GUI, so leaving out the generic auto-generate code I have: Under Graphslide_OpeningFcn handles.OutAirTemp = OutAirTemp; handles.SupAirTemp = SupAirTemp; guidata

Solving a symbolic equation with integer variables

时光毁灭记忆、已成空白 提交于 2021-02-11 12:14:35
问题 Why does the following return an empty solution? syms a b positive integer s = solve(a + b == 5, 'ReturnConditions', 1) This does work: s = solve([a + b <= 5, a + b >= 5], 'ReturnConditions', 1) It seems that I had a problem in general solving a system with degrees of freedom: Solving a symbolic equation system with degrees of freedom The solution over there applies here: s = solve(a + b == 5, [a b], 'ReturnConditions', 1) 来源: https://stackoverflow.com/questions/65748247/solving-a-symbolic

MATLAB: Computing euclidean distance in an efficient way?

删除回忆录丶 提交于 2021-02-11 12:13:24
问题 What I am currently doing is computing the euclidean distance between all elements in a vector (the elements are pixel locations in a 2D image) to see if the elements are close to each other. I create a reference vector that takes on the value of each index within the vector incrementally. The euclidean distance between the reference vector and all the elements in the pixel location vector is computed using the MATLAB function "pdist2" and the result is applied to some conditions; however,

Fibonacci Recursion Value tracer

隐身守侯 提交于 2021-02-11 07:55:15
问题 So I need to write a program which uses a recursive function to store the value of input arguments in the order they were made. e.g. If my function is [f trace]=fibo_trace(6,[]) it should return [f trace]=fibo_trace(6,[]) f= 8 trace= 6 4 2 3 1 2 5 3 1 2 4 2 3 1 2 With trace being the values with which the recursive call is being initialized and f being the 6th element in the fibonacci series. Here is my code function [f,trace] = fibo_trace(n,v) persistent ptrace; % must specify persistent v=n

Plotting just the endpoint of quiver

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-11 06:16:49
问题 I need to plot a block of points with small deviations from their equilibrium states. Using quiver it would look like this: And now I want to plot just markers located on the arrow tips. How to do that? Input data are U and V deviations (on cartesian axes), getting the X,Y coordinates of vector origins is not a problem. 回答1: You can't simply use something like plot(X+U, Y+V, 'o') because quiver applies an automatically computed scale to U and V so that all arrows fit nicely in the figure. You

Plotting just the endpoint of quiver

旧城冷巷雨未停 提交于 2021-02-11 06:16:00
问题 I need to plot a block of points with small deviations from their equilibrium states. Using quiver it would look like this: And now I want to plot just markers located on the arrow tips. How to do that? Input data are U and V deviations (on cartesian axes), getting the X,Y coordinates of vector origins is not a problem. 回答1: You can't simply use something like plot(X+U, Y+V, 'o') because quiver applies an automatically computed scale to U and V so that all arrows fit nicely in the figure. You