Cannot plot solution of an ODE using a large domain - octave

I'm trying to solve a system of ODEs. I'm using the ode45d command like so:
[t,x] = ode45d(#f, (t = linspace(0,100,1000)'),
[sh0; ih0; rh0; sm0; lm0; im0; se0; ie0], [7], ones(8,1));
When I type the system of ODEs and this command in octave I get the right graph. The problem is that when I let the x-axis larger, the graph changes to something very strange.
When I let the domain of the ODEs bigger than 100, the only thing I get is a vertical line on the graph.
Is there someone who knows the function ode45d and its limitations, and who can tell me why this is happening?
Thanks in advance, and sorry for my English.

Related

Octave dataframe's problem with isna() function

I use Octave dataframe to read csv file but some columns can compute numbers of NA but some don't. How can I fix this?
enter image description here
I suspect it is about the columns with char type that does not work. How can I fix this? I want to use Octave for data science practice too. Thank you in advance.

how to fix this easy digital communication excercise using MATLAB

I have a problem in writing in MATLAB a program that modulates data bits, adds noise then demodulates it and calculate the bit error and the symbol error rate. The modulation used first should be QPSK. I have done the following,
N=100;
databits = randi([0 3],N,1);
hModulator = comm.QPSKModulator;
hModulator.PhaseOffset = pi/4;
txsig = step(hModulator, databits);
scatterplot(txsig)
grid on
SNRdB=-10
rxsig = awgn(txsig,SNRdB);
H = comm.QPSKDemodulator
hH.PhaseOffset = pi/4;
symdecoded=step(H,rxsig)
symerr(symdecoded,databits)
biterr(symdecoded, databits)
My first question is I don't think I am doing the bit error rate and symbol error rate correctly, can someone help me spot where the problem is? Where am I missing out?
I am then asked to repeat the same problem but make the changes needed to make it work with 16-QAM and 64-QAM by changing a parameter called CONSTELLATION.
I have tried using demod and ddemodce but these two functions are removed from matlab? Does anyone know how to proceed?
I dont know why you are using SNRdB=-10 dB?
Try for example positive numbers 0 10 20 30, and you may save symerr and biterr as the function proposes [number,ratio] = symerr(x,y)
number= numb of error and ratio = bitsTx/bitsRx
For m-qam better use modem.qammod try the help in matlab
Best regards and good luck

Strange output of a very simple code?

I'm very new to python, but I found this strange:
Code: I was typing in Sagemathcloud's sageworksheet file:
x=y+1
def f(x):
return y
x=-1
print(x)
print(f(x))
As an output, I kept getting 7 or sometimes 49, something quite randomnumbers no matter what value of x I input. Any insights please?
P.S. I'm trying to make it look like a code, but I'm, not sure how to do that, for example, def was in the next lmine after I typed: x=y+1.
If that's the only code you have, then y isn't defined before it is used. y will take the value of what was previously in the memory space it's using - and that may not even be an int which causes the randomness of the numbers you're experiencing.

New to Python - proficient with Matlab: getting error "IndexError: list index out of range"

As the title says, I'm proficient with Matlab and already have this function written there and it works great. I wanted to learn a new language and I've been pointed to Python so I figured I would write a simple function to get used to the syntax of Python and have something to validate what I've done. I wrote the function "Xfcn" (which is non-dimensional mass flow in rocket problems) and it gives me the correct number if I only use one value. Now, I'd like to plot the X-function versus Mach and validate with my Matlab version. I need to loop through some Mach vector then plot it. Plotting comes later. I'm getting the error mentioned above and I think it's a simple indexing problem, although I can't seem to figure out what it is. I've looked here and on Python's documentation center so hopefully we can resolve this quickly. I've also checked the "type" of "i", printed the range(len(Ms)) and get 0-49, by 1's, as I expect with the particular values of Ms 0-1 by equally spaced increments, also as I expect, so I cannot figure out where my error is. My code is below.
from Xfcn import Xfcn
import pylab as pyl
import numpy as np
Ms = np.linspace(0,1,endpoint=True)
X = []
for i in range(len(Ms)):
X[i][0] = Xfcn(Ms[i])
print X
print 'Done.'
Thanks for the help!
BL
You created x as a single dimensional list and are trying to access it as if it was multi dimensional

Matlab ode solver using the time in a function for 'value' in events

I've searched extensively, and thought I wouldn't be the only one having this problem, but it seems to look like I am.
I am solving an ode via ode15s (my problem can be stiff) and I use the 'Events' option to find my point of interest.
The problem is: the equation that I use in 'value' is depending (among other things) on the specific time (so value = f(t,y,y'), and I cannot find a way of passing the current time to this function, only the y vector is available.
Anyone has any ideas?
Thanks in advance and all the enjoy the rest of your holidays!
Sorry, made a really stupid error (used , instead of ;)...
You can just use the t argument as long as you set it in your #odefunction(t,y) as well as your #events(t,y).