I got the following syntax error while I want to plot values:
syntax error
>>> plot(freq1, abs(fft1/max(fft1)),xlabel('f(Hz)'), ylabel('Amplitude I(f)');
^
My definitions are as follows:
a=x+y+z; % a is a sinus mixture of different curves/functions
n1 = fa/0.05; % N is 50 ms
fft1=fft(a,n1);
freq1 = [0:deltaF1:fa-fft1];
plot(freq1, abs(fft1/max(fft1)),xlabel('f(Hz)'), ylabel('Amplitude I(f)');
EDIT: It would be nice stop voting me down, I know that question is not too interesting (please see below in the comment to the answer), thank you!
You have more opening brackets ( than closing ones ), that's a syntax error.
It should be:
plot(freq1, abs(fft1/max(fft1)),xlabel('f(Hz)'), ylabel('Amplitude I(f)'));
Related
When I type
round(1122700.625, 2)
I get 1122701
when I would expect 1122700.62 from my reading of ?round (nearest even)
Somewhat similarly for
round(205290.125, 2)
I get 205280.1
when I would expect 205290.12
round(205290.125,3) and round(205290.125,4) both give 205290.1
round(2.125, 2) gives 2.12 as expected
and
round(22222.125, 2) gives 22222.12 as expected
but round(222222.125, 2) gives 222222.1
and round(2222222.125, 2) gives 2222222
I have tried running R from the command line with --vanilla option with the same result (originally noted when using RStudio).
The help does also state "The realities of computer arithmetic can cause unexpected results" but
Am I missing something/what don't I understand?
Does this matter?!
I guess you looking for toFixed because the round only expect one param.
CLICK for ref.
It seems that the python code in R reticulate is not indenting automatically. E.g. when I write
if x < 0:
print("negative")
else:
print("positive")
the third line should move automatically at the same level of if but, it actually does not and I get the message IndentationError: unexpected indent (<string>, line 1)
Is this bug or can it be corrected?
This can be solved by correcting the indentation of you code, following Python rules :
You need to unindent the else so it's indentation match the if ones. Rstudio don't indent correctly for Python to this day.
if x < 0:
print("negative")
else:
print("positive")
In my *.Rmd file I'm writing something like this
$\text{Dia}_i = \max_{x, y \in C_i} d(x,y)$
And I was expecting this
but when doing bookdown::render_book(...) and controlling the results in my browser firefox I got
I found that this has something to do with the namelimits (first picture) and nonamelimits (second picture) but unfortunately I have no clue how to change the outcome.
Question: What kind of code chunk I have to add that I can switch between the two notations?
Thanks a lot in advance!
Edit_1
Can I mix these two types?! The goal is to have an inline formula with the desired apperance.
Edit_2
This is my Code - the three dots (...) are the magic/unknown code
And this is my desired output
But sadly I get this
My wish summerized
This should work, following https://stackoverflow.com/a/61979164/13249862:
Add this to your YAML header:
header-includes:
- \newcommand{\argmax}{\mathop{\mathrm{max}}\limits}
Then, you can write both equations:
This $\text{Dia}_i = \argmax_{x, y \in C_i} d(x,y)$, or this $\text{Dia}_i = \max_{x, y \in C_i} d(x,y)$.
Result:
I am learning from the book Learn Python The Hard Way 3.6, by Zed Shaw
There are a series of 6 target.write commands towards the bottom of the script and he wants me to simplify them into a single target.write command using strings formats and escapes. However, I am stuck.
Here is the original code:
from sys import argv
script, filename = argv
print(f"We're going to erase {filename}")
print("If you don't want that, hit CTRL-C (^C).")
print("If you do want that, hit RETURN.")
input("?")
print("Opening the file...")
target = open(filename,'w')
print("Truncating the file. Goodbye!")
target.truncate()
print("Now I'm going to ask you for three lines")
line1 = input("line 1:")
line2 = input("line 2:")
line3 = input("line 3:")
print("Im going to write these to the file.")
target.write(line1)
target.write("\n")
target.write(line2)
target.write("\n")
target.write(line3)
target.write("\n")
print("And finnaly, we close it")
target.close()
So far I have tried
target.write(line1),(line2),(line3)
but this gives a logical error of only writing to one line not all three.
target.write(line1) + (line2) + (line3)
with this one I get error
'unsupported operand types for +: 'int' + 'str'
target.write(line1),\n,(line2)\n(line3),\n
with this one I get error:
unexpected character after line continuation character
(<string>,line 22)
I have been googling and searching here for answers but have not found anything. One person posted a very similar question except for Zed's 2.7 book. However I am reading Zed's 3.6 book so the answers were no help to me unfortunately.
I'm not sure what you have and haven't covered so far in the book as I'm not familiar with it but one way to do what you want is to format the string first and then pass it to the write method like this:
target.write("{0}\n{1}\n{2}\n".format(line1, line2, line3))
Hi I am new to scilab and don't have much mathematical background.
I have been following code for another example and am being shown error 10000 for the following code:
function [z]=f(x,y)
z=0.026*(1.0-(y/ym))*y;
endfunction;
ym=12000;
x0=1950;y0=2555;xn=5;h=10;
x=[x0:h:xn];
y=ode("rk",y0,x0,x,f);
disp("x y")
disp("--------")
disp([x'y']);
function z=fe(x)
z=ym/(1-(1-ym/y0)*e^(-k*(t-t0)));
endfunction;
xe=(x0:h/10:xn);
n=length(xe)
for i=1:n
ye(i)=fe(xe(i));
end;
plot (x,y,'ro',xe, ye,'-b');legend ('rk4','Exact',3);
xtitle('solving dy/dx=k(1-y/ym)y','x','y');
I have worked through several other error messages. I am lost and don't know if the problem is in the code or the way I set up the problem. The following is the current error message:
!--error 10000
plot: Wrong size for input argument #2: A non empty matrix expected.
at line 57 of function checkXYPair called by :
at line 235 of function plot called by :
plot (x,y,'ro',xe, ye,'-b');legend ('rk4','Exact',3);
at line 25 of exec file called by :
I would appreciate any help.
Thanks
Start by adding clear as first statement, this will erase all variables before running your function. In the above script you don't declare ye.
Also the statement x=[x0:h:xn]; is strange with those values for x0,h and xn. You are now trying to get a list of x-values starting at 1950 and with positive steps of 10 up until 5 is reached.
I would recommend to try each line and see if the outcome is as expected. You do not need to know everything about the code, but probaly x and y should contain at least some values. The error is telling you that it expected a non-empty matrix for argument 2. This is y, so essentially it is telling you y is empty.