Answered
Python function to Matlab
As @Anagha Mittal and @Akanksha Shrimal have stated there is a function in Financial Toolbox called movavg. However I'd recomme...

4 years ago | 0

Answered
Calculate the distance between points in a large data set
John showed you one approach. Two others that come to mind are to use the hypot or vecnorm functions. % Sample data xy = rand(...

4 years ago | 0

Answered
MATLAB gives the integer value of subtraction when the difference between numbers is large.
What's the distance from the elements of b to the next larger number? b = 10^23 distance = eps(b) If you were to add 1 to b, ...

4 years ago | 0

Answered
MATLAB function run in 2021a producing graphics handles as unique doubles (pre-2014 behavior) rather than handle objects
Without seeing what you're doing I'm only guessing, but I suspect you're preallocating an array as a double array and assigning ...

4 years ago | 2

| accepted

Answered
Split matrix into square cells
Use the histcounts2 function.

4 years ago | 2

Answered
How to publish as pdf from command tab
To do this using the publish function use the codeToEvaluate name-value pair argument as shown in the "Generate HTML View of MAT...

4 years ago | 1

| accepted

Answered
how to draw contour plot
There are a couple potential problems here. Did you really mean to make x a 1-element vector or did you mean to go from 0 to 1 i...

4 years ago | 1

Answered
Hi, do you know why I can't open the variable window by doule clicking any variables?
My suspicion is that you've written or downloaded a function with the same name as one of the functions included in MATLAB that ...

4 years ago | 1

Answered
To get x and y coordinates of the edges in a Delaunay Triangulation
Let's build a sample delaunayTriangulation using the first example on its documentation page. rng default; P = rand([30 2]); ...

4 years ago | 1

| accepted

Answered
Event in ode45 doesn't work
You don't want to use == in defining the first output of your event function. That will make the value of your event function 0 ...

4 years ago | 0

Answered
Create MException object with a custom non-empty stack (without actually throwing it)
Preallocate a cell array. M = cell(1, 3); Run the code that may throw an error. If it does, catch the error in the appropriate...

4 years ago | 0

Answered
Animated 3D Scatter Plot
Rather than recreating the scatter plot each time, I'd apply the first of the techniques listed on the Animation Techniques docu...

4 years ago | 1

Answered
Why this piece of code gives error?
Either make your CostFunction variable a function handle to the fun4sn0 function (which is the approach I'd prefer): CostFuncti...

4 years ago | 0

| accepted

Answered
ode return NaN :(
What is at time t = 0? By your formula 14 it is times other stuff. Let's ignore that other stuff and look at the value of that...

4 years ago | 1

Answered
Draw the 3-D plot for the function f(t)= (t, t ^2, t ^3), where 0 <= t <=100.
You're close. f=(t,t^2,t^3); Instead of trying to define f like this (and then not using it) define the variables x, y, and z ...

4 years ago | 0

| accepted

Answered
I got something wrong with the hep document
Check if you've written or downloaded a split.m file that's taken precedence over the split function included in MATLAB. which ...

4 years ago | 1

| accepted

Answered
Property value validation with values from file
The census.mat file contains two variables, cdate and pop. whos -file census.mat Let's write a function that will retrieve the...

4 years ago | 0

| accepted

Answered
I want to extract the linear x and y data from the overall data. I have version 2017a in which "ischange" function is not present any alternatove method
So you want to detrend your data? The detrend function has existed since before release R2006a.

4 years ago | 0

Answered
Parse error at " end "
When you get a parse error like this, look for the Code Analyzer messages in the Editor's right margin. Of particular importance...

4 years ago | 0

| accepted

Answered
Where can I find Fcn block in simulink in matlab R2022a?
Which of the blocks in the User-Defined Functions library do you want to use? I'm guessing you want either MATLAB Function or I...

4 years ago | 1

Answered
How to get the sum of the rows of a matrix?
Use the sum function.

4 years ago | 0

| accepted

Answered
I want the matlab code of Discrete Tchebichef Transform and its inverse version
https://www.mathworks.com/matlabcentral/answers/88670-is-there-a-code-in-matlab-for-discrete-tchebichef-transform-dtt?s_tid=answ...

4 years ago | 0

Answered
Answers of equation are mismatch
Use element-wise operations instead of array operations. h = linspace(24,62.5,20); % Height of Trapzoid w = 81-0.54...

4 years ago | 1

Answered
Simplifying Complex expressions in Matlab Symbolic Toolbox
Did you mean to assume that x, y, xv, yv, and/or T are real? syms x1 y1 real syms x2 y2 z1 = x1 + 1i*y1 z2 = x2 + 1i*y2 z1c...

4 years ago | 0

Answered
weird Matlab+Windows Scheduler Behavior
The Add Arguments is set to -r -nodesktop -nosplash "run GBB_lvl1" So you're telling MATLAB to run a command (with the -r optio...

4 years ago | 1

| accepted

Answered
Create variable number of random streams (unique, deterministic, independent)
See the "Substreams" and "Restore State of Random Number Generator to Reproduce Output" sections on this documentation page for ...

4 years ago | 0

| accepted

Answered
How to increase number of contour lines in a plot?
f = @(x1,x2) (x1-5).^2+(x2-4).^2; % Vectorized the function h = fcontour(f,[0 10 0 10]); % Let MATLAB choose the number and hei...

4 years ago | 1

Answered
Equality operator error with exact same value
This is not a bug. See the section "Avoiding Common Problems with Floating-Point Arithmetic" on this documentation page.

4 years ago | 0

| accepted

Answered
Minimize a function under several constraints
Any values that satisfy your first two constraints are a solution to the problem since your objective function is constant. Subs...

4 years ago | 0

Answered
How to create a function that checks if a word is a palindrome?
A recursive approach, like you've tried to implement, can work but one important aspect of recursion is the base case. This is t...

4 years ago | 0

Load more