Community Profile

# Bjorn Gustavsson

### UIT, the Arctic University of Norway

285 total contributions since 2015

View details...

Contributions in
View by

Spring mass system subjected to impulse excitation
You seem to have misunderstood how matlab integrates ODEs. Your ODE-function, impulse, should return the derivatives, and , at...

1 day ago | 0

Is It Necessary to Select an Odd Span for Smoothing Data Using Moving Average Filter?
You can check what happens when smooting by averaging over an even number of points. simply use convolution to carry out the ave...

2 days ago | 0

dispersion relation normalization ion acoustic
Expand the definitions of and . Then you get a proper expression for the ion-accoustic dispersion relation. To plot it in some ...

3 days ago | 0

Convert interpolation function to symbolic
You already get a piecewise polynomial out of pchip. That is a symbolic function - though not on the form expected by the symbol...

16 days ago | 1

| accepted

How to get a value from inside a function?
So we know something about your functions, but not much more than the most general stuff. If you write your function fun_a somet...

20 days ago | 1

| accepted

how to extract variables from ode45
My pedestrian-layman approach to this type of problem is to integrate the ODE, typically with t = t0:dt:tend, then when I have y...

21 days ago | 0

Infinite recursion in code to graph second order differential equations
Let's analyse what's happening here. When you call odefcn from the command-line 1, the first thing matlab does is to overwrit...

22 days ago | 0

| accepted

Scatter 2D plot with specific colorbar
You can try something like this: imagesc % Just to get something to show axP = get(gca,'position'); % Create axes for colorba...

26 days ago | 0

| accepted

whats is presice compute time in matlab
These fluctuations are "kind of expected", your computer does a lot of other stuff in addition to running matlab which gives the...

27 days ago | 0

FFT of sine wave shows unexpected spectral widening
Try this: subplot(1,2,1) plot(templeS) axis tight ax = axis; axis([[-30 0]+ax(2) ax(3:4)]) subplot(1,2,2) axis tight ...

28 days ago | 0

| accepted

It seems to work just fine as far as I can see. When I compare: jd0 = juliandate(2020, 2, 14); jd0p100 =juliandate(2020, 2, 14...

1 month ago | 0

How to find the best parameters to fit damped oscillations curves
If you plot your data you should be able to see that the zero-crossings are increasingly further apart. That means that your mo...

1 month ago | 1

How can I improve code efficiency?
First step of improving code is to run the scripts and functions with the profiler on (seel documentation and help for profile) ...

1 month ago | 0

Some question about a special code for solving an ODE system by Runge-Kutta method
Since u1 and u2 depends on p1, p2 and p3, that in turn will depend on time, you have 6 coupled ODEs. The best(?) way to solve th...

1 month ago | 0

| accepted

Curve fitting of a custom equation with a predefined value
For this type of problems I typically use the basic optimization-functions of matlab - either fminsearch or lsqnonlin depending ...

1 month ago | 0

| accepted

how to get eigenvalues of a function matrix?
To calculate the eigenvalues of H you have to chose, either to use your implementation where H is a handle to a function returni...

2 months ago | 0

| accepted

How do I create a new folder each time I run a code?
This is easily solved: dirname = fullfile(path_2_root_dir,sprintf('NewFolder-%s',datestr(now,'yyyymmdd-HHMMSS'))); mkdir(dirna...

2 months ago | 0

Images don't show properly with imshow after certain calculation
When you do things like this the errors are always (in my experience) in different normalizations and type-castings. To work the...

3 months ago | 0

| accepted

Press " " to rename 4 instances of "VariableName1" to "VariableName2"
That ought to be the return key... HTH

3 months ago | 0

How to compute SVD of a matrix without using in-build SVD command?
So this is a homework task, right? (Unless you come up with a good reason this is the case everyone have to come to this conclus...

3 months ago | 0

analytical solution of ODEs
This should be done thisly: syms r syms T(r) dTdr = diff(T) d2Tdr2 = diff(T,2) T = dsolve(1*d2T+((1/r)*dT) ==1,T(0.005)==20...

3 months ago | 0

How to graphically/interactively select region of interest from 3D point cloud data
In newer versions of matlab there seems to be just such a feature, see: ROI.CUBOID For older versions of matlab (I vaguely rec...

3 months ago | 0

| accepted

Obtaining a equation in two variables (x and y) from a set of data points
What you should do depends on your objective. If you very explicitly want a function you could use spap2 (and perhaps some of it...

3 months ago | 1

| accepted

Hello, we have received a Matlab code in school and the assignment is to explain what it means. I wonder if anybody could take us through the code and explain it?
At the matlab command-line prompt type: dpstop in nameiofscript where nameiofscript is the name of the script-file. Then you r...

4 months ago | 0

How to obtain CDF from large dataset?
Have a look at the help and documentation of the function ksdensity - that is one way to do this with the least amount of assump...

4 months ago | 0

Difference in frequency domain between mp3 and wav
There are some small differences. You should also try to compare the spectrograms of the two signals, see the help for spectrogr...

4 months ago | 0

How to edit matlab saved file?
I think something like this should work: filename2edit = 'something.mat'; load(filename2edit,'X2change') X2change(3) = 12; s...

4 months ago | 0

I would like to plot Histogram and relative frequencies from a given dada.txt. I already plot time series plot for the given data. KIndly help me to plot histogram and relative freqs.
Have a good look at the help and documentation of histogram function. It should let you solve this task easily. HTH

4 months ago | 0

Solving 4th order ode problem
In general you convert a high-order ODE to a set of first order ODEs like in this example below (I will use a simple equation of...

4 months ago | 0