Code Definition and 908 Threads

  1. J

    Normal distribution starting with a uniformed distribution

    Hi comunity! I need to make a code o a normal distribution of velocities, starting whit a random secuence uniformly distributed between [0,1]. I am using FNT95, with Plato. I want to obtain a ''for'' bucle with I=1,N for the velocities. It is importan for the distribution to have sigma defined...
  2. G

    Morse Code Project: Building Circuit for 7 Segment Display

    Homework Statement Hi everyone. I am currently embarking on a Morse Code project which involves building a circuit to display Morse codes, eventually displaying the Morse code with a 7 segment display. I am currently stuck at the first stage as I am not sure of what to do, i.e. what chips to...
  3. G

    C/C++ VCSEL, spin-flip model, c or c++ code?

    Is there any c or c++ written spin-flip model for simulation of dynamics in VCSELs available? Thanks.
  4. Matterwave

    Fortran [FORTRAN] Code misassigning values

    Hi guys, I can't figure this one out. Here I am working with a piece of code which should read in a grid of 2 arrays, a radius array and an electron fraction array. The code looks like this: subroutine varelec_init(varelecfrac,elecprofile,effilename,elecfracname) integer ...
  5. thankz

    Simple Pivot Table Code Example: Step-by-Step Guide

    where can I find an example of a SIMPLE snippet of code used to create a pivot table?
  6. A

    Write PEP8 Code: Display Full Name & Major

    Homework Statement You are to write a program that will display your full name and your major (First Name, Middle name and Last Name) on the Terminal Input/output (I/O) screen.[/B] Homework EquationsThe Attempt at a Solution I was trying to get the screen to say "What's your first name?"...
  7. A

    Write a Pseudocode for the following instructions:

    Homework Statement - Calculating the factorial of a number N - For simulating the roll of a die 200 times (include the calculation for the relative frequency of the number 4 in the upface of the die within the 200 rolls) Homework Equations None? The Attempt at a Solution I am taking this...
  8. Alexi-dono

    Python [python] How can I get my OS to pick this up as entropy?

    So I am going to be making some keys; and I want to make them more random... So I made this: #I know that the code is pretty crude, but it works. #P.S. it is an infinite loop, run at your own risk import random from random import randint import string import time x=1 n=randint(5,90)...
  9. beyondlight

    MATLAB Optimize code for a blob-detector (MATLAB)

    The blobdetector consist of the following functions: gaussImage: Filters a image with a gaussian filter gaussPyramid: Uses gaussImage to filter the same image several times with different std. diffOfGaussians: Uses gaussPyramid to compute the difference between consecutive filtered images...
  10. N

    C# This[r, c] saw this in some C# code, how is it possible?

    Hey all, I was looking at some example code where they said "this[r, c] = sourceMatrix[r, c];" where sourcematrix is double[][] but its in a custom local class, the code runs and works. but I am confused as to what "this[r, c]" does, how can a custom class be an array of doubles at the same...
  11. P

    C/C++ How Should I Modify My C++ Code to Start Time Calculation from Zero?

    #include <iostream> #include <iomanip> #include <cmath> using namespace std; int main() { cout << "Enter the total time: "; double t; cin >> t; cout << "Enter the step-size: "; double step; cin >> step; double steps = ceil(t/step); const double a = 9.806...
  12. J

    A mathematical way to analyze code?

    In the last semester I was taking a microcontroller programming course. For the programming assignments, our professor would hold an extra credit competition where we competed for the smallest, fastest, and most energy-efficient code for the same application. It got me thinking. What I'm...
  13. D

    Can You Decode This List of Numbers into a Message?

    The encryption method is extremely simple and the first letter is already in plaintext (the character number that is). The plaintext is plain english. [79, 32, 79, 39, 45, 39, 112, 21, 50, 64, 37, 5, 107, 4, 36, 87, 35, 81, 48, 94, 57, 92, 46, 93, 125, 9, 102, 70, 42, 69, 51, 86, 92, 5, 106...
  14. I

    C/C++ C++ Code Display: Understanding Output of Exam-Related Question

    I came across this question while studying for a C++ exam. What is the screen output of the code? #include <stdio.h> int main(){ int i, counter=0; for(i=0;i<100;counter++){ i++; ++counter; } cout<<i<<' '<<counter<<'\n'; return 0; } What will this code display...
  15. P

    C/C++ C++ Programming Problem: Adding Streams to a Pre-Existing Code

    I have been given a project to modify my pre-existing code to satisfy these guidelines: - Create a file called "sides.txt" and put it in the same folder as your program. - The file contains multiple lines with each line having the three sides, separated by white spaces, e.g., 3 4 5 6 8 10 5...
  16. ahsanamin

    Code for Simulation of SDEs using Girsanov Theorem

    http://wilmott.com/i/dominant/block.gif I have worked with generation of transition probabilities of mean reverting CEV type stochastic differential equations using Girsanov theorem. A variable grid is generated and Transition probabilities are calculated from the well known analytic...
  17. I

    Inductor Color Code: 68mH Violet Gray Brown Silver

    hi, i just bought an inductor that was labeled 68mH, but the colors are violet gray brown silver. doesn't this make it 680uH (0.68mH)?
  18. L

    Need help understanding part of this assembly code

    CHARI 0xFE,d ; read 1stchar CHARI 0xFF,d ; read 2ndchar LDBYTEA 0xFE,d ; load 1stchar ADDA 0xFE,d ; add 2ndchar to low byte(big endian!) ANDA 0x0F,i ; keep low 4 bits ORA 0x30,i ; convert to ascii STBYTEA 0xFD,d ; store for output CHARO 0xFD,d...
  19. Math Amateur

    LaTeX Latex code for the functor Hom_R( _ , X)

    Can someone please help me with the correct Latex code for the functor Hom_R( _ , X) When I try to get the correct symbol for the functor I get $$Hom_R( _ , X)$$ , that is I get a symbol without the _ displayed. Can someone please help me with the correct code? Peter
  20. STEMucator

    [C] The usage of ? and : when cleaning up recursive code

    I noticed some interesting utility in using ? and : when writing some recursive code out of boredom. I thought I'd share some of the code for those interested. These were written in C, and I must say they simplify a lot of code. #include <stdio.h> #include <math.h> /* Return x raised to the...
  21. I

    MATLAB Line following Matlab Code. How to Start?

    So we're using NXT 2.0 and MATLAB to program a robot to follow a white line through a maze. I'm using a light sensor, color sensor and an ultrasonic sensor in the process. Any programming/Coding ideas of how i should start? This is the maze...
  22. A

    MATLAB Could you check (if statment block) in my MATLAB code please?

    function RunlogisticOscilnumericalfisherfixedn0omega omega=1; N0=1; k = 10; A = 1; p0 = 0.1; tspan=(0:0.1:4); [t,p] = ode45(@logisticOscilnumerical,tspan,p0,[],omega,k,N0); figure(1) plot(t,p) xlabel('Time') ylabel('p') P = @(T) interp1(t,p,T); f = @(t) ( ( A.*( ( N0.*...
  23. Math Amateur

    LaTeX Latex code for the class SE of short exact sequences in Mod_R

    I just uploaded a post on the class SE of short exact sequences in Mod_R ... and tried to use Latex Code to achieve the same fancy script for S and E as Paul E Bland used in his text "Rings and Their Modules" ... but seemingly did not achieve the right script for S (E seems OK, or at least...
  24. S

    Fortran Error 6404 when running fortran code in visual studio

    I am trying to compile several libraries of FORTRAN code and getting the error message as can be seen in the screen shot. As I do not have any experience with FORTRAN I am not sure what is wrong in the line highlighted line. Any help would be greatly appreciated! Thanks a lot! :-)
  25. A

    MATLAB MATLAB code for Computational Fluid Mechanics

    Hello guys, I'm writing to get some help on an exercise I've been thinking but I can't get to solve. I have to write the code for the Example 8.5 of the book White, Fluid Mechanics. Here is the problem and the solution I have to obtain. It is about one duct that has three sections in which I...
  26. C

    Write a state that will compute f=x/y^2 in maple

    Homework Statement Using maple cw version, trying to write a state that will compute f=x/y^2 over several iterations. y^2 is changing but x is dependent on a value input my user. I don't really know how to write the loop? I need the loop to run on an interval of different y values that I can...
  27. F

    Python Python code using Process class

    Homework Statement I have the following code (please see below). I want it to return [2,4,6,8,10] which is the function evaluated at the given list [1,2,3,4,5]. I want to do this using the process command. My problem is: print A returns [None, None, None, None, None] But I want it to return...
  28. F

    Unbreakable Code: Moby Dick Method

    I heard this method of creating a code described in a movie a long time ago. Two people want to send encoded messages to each other by mail(or now email). To encode their messages they both buy the same novel , let's say Moby Dick. To write the message they use a system where a triple set of...
  29. STEMucator

    Why Does One Piece of Code Run Slower Than Another?

    Homework Statement Not homework, but I'm wondering why a certain piece of code seems to run faster than another. Homework EquationsThe Attempt at a Solution I'll mention a few relevant structs to be more clear: struct intlist { int *elems; int capacity; /* Maximum number of elements...
  30. B

    Digital design code converter help

    Homework Statement design a code converter that converts a decimal digit from the 8 4 -2 -1 code to BCD. Homework EquationsThe Attempt at a Solution so i listed out the BCD order from 0 to 9 and listed the weighted 8 4 -2 -1 code so that the weights would equal to the BCD equivalent. 8 4 -2...
  31. G

    Asymptotic running time of code segments

    I'm trying to grasp some basic concepts of analyzing code segments. Not sure if I have the right thought process. Can't find many examples online. Homework Statement A.) for (i=1; i<n; i++) for (j=1; j<n; j++) return 1 Guess: Theta(n) because both loops go to (n) and they're...
  32. J

    Do Empty spaces/text slow down code?

    If you are say running a for-loop with 5000 cycles, will 2 empty spaces and say 3-comments slow this operation down?
  33. T

    C/C++ How to write C++ code using SGP4 to propagate satellite position

    Greetings all ! I really hope this is the right sub-forum for my question, I have chosen it because I've seen TLE being mentioned a couple of times around here. I have done some reading on astrodynamics and orbital mechanics, but I am relatively new to coding. I would like to write some C++...
  34. H

    Algebraic coding theory- Golay Code

    Homework Statement does anyone know why C24 (the extended Golay Code) doesn't have any words of weight 20? I know that it only has words of weight 0,8,12,16, & 24, but why is 20 skipped here? Homework Equations I am asked to deduce this from the fact after I have shown that the code does...
  35. J

    Java Why does the output show 1 and not 3?

    Consider the following java code int a=1; if (a != 0) { int a=3; } System.out.print(a); What is the output A. 0 B. 1 C. 3 D. No output. A compilation error occurs The answer is B. I want to ask why the output shown will not be 3. As the 1 is not equal to 0, should the ' int a '...
  36. mesa

    Trouble with understanding MatLab code

    Homework Statement A = [1 3; 2 4]; %Okay, so we are starting with this matrix N = 2; %Here we are setting N equal to '2' for k = 1:N %So here we have a 'for loop' for variable 'k' starting at 1 in increments of '1' up to 'N', which %happens to be '2' so once this function gets to '2' it...
  37. M

    MATLAB Why Does Matlab Say Matrix Must Be Square When Using mpower?

    When running the following code on Matlab: >> y(i) = y(i-1) + (0.5 * y.^3 * exp(t^2 + t))*h I get the error: ? Error using ==> mpower Matrix must be square. It seems fairly simple but I'm not quite sure what I'm overlooking. Any help with regards to what I may be doing wrong would be...
  38. T

    How Can Students Access SCDAP/RELAP Source Code?

    :(as a student, any help would be appreciated.
  39. Greg Bernhardt

    Read this before posting code GeSHi Syntax Highlighter

    Physics Forums now supports GeSHi syntax highlighting for nearly 200 programming languages. Simply hit the + button on the editor. Select the code option, use general code, type in your code. Then in the first bbcode tag put in the language you want to use. For example: C AREA OF A TRIANGLE -...
  40. BasicComplex

    Redundancy of the genetic code enables translational pausing

    Thoughts on this? http://journal.frontiersin.org/Journal/10.3389/fgene.2014.00140/full The codon redundancy (“degeneracy”) found in protein-coding regions of mRNA also prescribes Translational Pausing (TP). When coupled with the appropriate interpreters, multiple meanings and functions are...
  41. Matterwave

    Fortran [Fortran] A piece of code that confuses me

    Hello all, There is a subroutine in the code I'm working on that looks like this: subroutine onestep(iter,iegy,icos,jcos,iphi,rinit,rfin, & & v2,v2bar,hel,helbar,drdis, & & psib,psie,psibarb,psibare,err) use params use helectron use angles use neutrinodist use parallel...
  42. P

    ASCII Code for B7.CFWhat is the ASCII code for the hexadecimal number B7.CF?

    Homework Statement Give the ASCII code for the hexadecimal number B7.CF (including the code for the hexadecimal point) The Attempt at a Solution This was one of the questions given on a problem sheet in my computer science class. I missed the exact lecture when this was taught so I...
  43. 1

    Fortran Help with Debugging Fortran Code | Plato Compiler

    Hey everybody, I am a mechanical engineer and new to Fortran(I have decent experience in programming in C, Matlab and understand languages similar to them). However the Fortran programming structure is new to me. Hence I am facing problems debugging a Fortran code. Here is the link of the code...
  44. adjacent

    Python Increasing the efficiency of a python code.

    Here is a python function to check whether a given list or string contains duplicate values: def has_duplicates(x): t = [] for i in x: if i not in t: t.append(i) if t != list(x): return True else: return False But I am sure this approach will be slow for...
  45. 1

    Fortran Fortran Code Help for Mechanical Engineers | Solving Debugging Issues

    Hey everybody, I am a mechanical engineer and new to Fortran(I have decent experience in programming in C, Matlab and understand languages similar to them). However the Fortran programming structure is new to me. Hence I am facing problems debugging a Fortran code. Here is the link of the code...
  46. I

    Fortran Run Fortran Code - Tips from Ilango

    Dear all, Let me introduce myself first. I am Ilango from India. I am new to Fortran, mostly working on Matlab, Modelica & Dymola. Working in an automobile company I was required to go through some battery models and hence landed at this page. http://www.cchem.berkeley.edu/jsngrp/fortran.html...
  47. R

    MATLAB Solving Steady State Heat Conduction Eqn w/ MATLAB

    HI guys,this is my first programming experience , i have developed an MATLAB code for steady state heat conduction equation , on governing equation dt2 /dx2 + dt2/dy2 = -Q(x,y) i have solved this equation with finite difference method, As far as i know if we increase the mesh size it leads...
  48. R

    Maintaining Legacy Code: Pros, Cons & Analysis

    I've been maintaining and updating some legacy code for a while at my job. These Dilberts came up the other day http://www.dilbert.com/2014-08-11/ http://www.dilbert.com/2014-08-12/ I see people disparage others work/code all the time, and it frustrates me. I give people credit /...
  49. N

    How do I troubleshoot my EEPROM test code problem?

    This simple code is test the write and read of EEPROM. Firstly the LED at P1 will have all LED on, after a sec, have the P1 will have LED on. Next, code is to write 01010101B into the EEPROM. CJNE will check to see if it is written. But, after comparing, the data isn't similar...
  50. S

    How to Resolve MCNP Depletion Code Syntax Errors?

    Hello, I am a graduate student attempting to run evaluate the depletion of a ceramic film attached to the moderator-side of the fuel clad. I am having some issues with my MCNP syntax/code and I was wondering if one could assist. My input file is attached. I am not looking for someone to...
Back
Top