Octave - How to plot an "infinite"(= Defining the function on [0:35916] for me) sawtooth function [closed] - octave

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I know how to plot a sawtooth function (thanks to another forum) but only on the domain [0:10] thanks to the following code which is actually working :
t=0:0.04:10;
A=1;
T=1;
rho= mod(t * A / T, A);
plot(t,rho)
A=the amplitude, T=the period,t=the time interval.
The problem is that I need the same function on the domain [0:35916] but when I try to adapt this code to do so (eg by extending the time interval), I get an error and I don't understand why.
error:
plt2vv: vector lengths must match error: called from plt>plt2vv at line 487 column 5 plt>plt2 at line 246 column 14 plt at line 113 column 17 plot at line 222 column 10

Simply modifying the original upper limit of your interval from 10 to 35916 should do the trick:
t=0:0.04:35916;
A=1;
T=1;
rho= mod(t * A / T, A);
plot(t,rho)
The code above yields the following image:
Of course it is up to you to adjust A and T to suit your needs.

Related

Fatal: Syntax error, ")"expected but identifier found [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
TOTAL [X] :=
(0.1 tomat*harga tomat ) + (0.2 cabe*harga cabe) + (0.3 kol*harga kol)+
(0.4 ikan*hargaikan)+ (0.5 tahun*hargatahu) + (0.6 tahu*harga tahu);
Each of the six sub expressions has syntax errors. For instance
0.1 tomat*harga tomat
You can't omit operators like you do in maths. So perhaps what you meant is
0.1 * tomat * harga * tomat
Or perhaps harga tomat is meant to be a single variable. Variable names cannot contain spaces. So you'd need to rename it without a space.

Wy decimal numbers are not stored as expected in mysql [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I'm trying to save numbers in decimal data type filed formated (10,4), but it's not stored as expected ie. 13850 changed to 13.0000 any help.
this is my code:
$c_price = $unit_price*$rate;
$expense->c_price = number_format($c_price, 4);
$expense->c_total = number_format($quantity*$c_price, 4);
Here c_price and c_total values are changed.
Increase the length of digits:
(19,4)
it will work.

function in Haskell that can solve an equation [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I need to write a function in Haskell that can solve the following problem(physic_problem):
What is the height (in a whole number of meters) of the shortest building that you could drop a ball from such that it would take at least 5 seconds to hit the ground?
The equation can be found here http://en.wikipedia.org/wiki/Equations_for_a_falling_body
I really tried hard on this and i need help!
Thank you so much!
Consider for instance this,
g :: Double
g = 9.81
dist :: Double -> Double
dist t = g * t^2 / 2
Then,
> dist 5
122.625
Additionally you may want to create a module out of the equations in that Wiki.
Update
For delivering an integral value consider for example
dist' :: (Integral a) => Double -> a
dist' t = ceiling $ g * t^2 / 2
Here we use ceiling (upper bound), yet note Converting to Integral for other rounding functions. Hence,
> dist' 5
123

how to design grid and blocks in cuda fortran for a 3-d array [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I am new to Cuda fortran. I have never worked with higher dimension grids. I just thought to start with this problem, in which i have to assign 1 thread to each cell of a 3-d array of size 46*46*19. Please can someone help me how to design the grid and blocks for this type of array and to compute the thread indices for that.
any help will be appreciated.
I have come up with this, but i don't know how to compute the thread indexes
type(dim3) :: threads,blocks
threads=dim3(16,16,4)
blocks=dim3((xDim + threads%x - 1)/threads%x,(yDim + threads%y - 1)/threads%y,(zDim + threads%z - 1)/threads%z)
The code you've shown in your question is what you would use to set up the kernel launch.
Inside the kernel you could use code like this to generate thread x,y, and z indices:
idx = (blockIdx%x-1) * blockDim%x + threadIdx%x-1
idy = (blockIdx%y-1) * blockDim%y + threadIdx%y-1
idz = (blockIdx%z-1) * blockDim%z + threadIdx%z-1
This would create zero-based indexing. You could omit the -1 at the end of each line of code above to create one-based indexing.

ROUND IN SQL Works but for this case what to do in MYSQL [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need to round the decimals like :
1.00 ->1.0
1.987->1.98
1.93-> 1.93
1.07->1.07
How to do this in mysql?
Here goes some documentation
http://dev.mysql.com/doc/refman/5.0/en/mathematical-functions.html#function_round
Quick answer:
mysql> SELECT ROUND(1.987, 2); = 1.99
OR More what you are looking for
truncate(1.987, 2) = 1.98
From Mysql decimal: floor instead of round
This only makes a difference if you are outputting the number (numerically, 1.0 = 1.00). So:
(case when format(num, 2) = '1.00' then '1.0' else format(num-0.005, 2) end)
The -0.005 is to overcome the fact that format() rounds rather than truncates.
Just like that:
SELECT if(NUMBER mod 1=0,ROUND(NUMBER,1),ROUND(NUMBER,2));
eg.
SELECT IF(1.00 MOD 1=0,ROUND(1.00,1),ROUND(1.00,2)); => 1.0
more info