Code Definition and 908 Threads

  1. S

    Mathematica Optimize Your Mathematica Code with These Helpful Tips and Tricks

    First of all, this might give seasoned Mathematica users some serious eye sores cause I'm a newb at this xD f[x_] := (1^-9) (Exp[38.629 x] - 1); data = Table[if[[f[x], {x, -5, 5, 0.01}] > 0.005, 0.005, f[x]]]; ListPlot [data, DataRange -> {-5, 5}, Joined -> True, PlotRange -> {0, 0.01}...
  2. S

    C code and seven segment display

    I need to write some c code that displays a counter value on four 7 segment displays. The number should increment by one every time a button is pushed. I cannot test this code as my home computer will not run Quartus 2 so I am working blind at the moment, but I would still like to ask some...
  3. H

    MATLAB MATLAB code has stopped working

    A few months ago my hard drive crashed and I managed to recover the data and I tried to run some of my old programs (one solving an ODE via Newton's method. Before the crash, the error was 10^-8 after around 3 iterations, now it won't converge. It looks fine, ithe than writing the code from...
  4. P

    I really with a MATLAB iteration code

    Homework Statement Hello, I want to obtain a solution to a, where k is a constant. The formula is: k/a = tan(a) I need to write a MATLAB code for this but I have been struggling for hours. And I must send the project to my professor in an hour. :( Homework Equations I know that I need to...
  5. A

    LaTeX How can I include MATLAB code in Latex without encountering errors?

    I need some kind of environment in Latex where you can write whatever you want without it interpreting it. The reason is I need to include a MATLAB code. Most places I go says I have to use the lstlisting environment, but that doesn't work. Or at least I get this error: ! Package inputenc...
  6. A

    What does the following lines of C source code mean?

    [b]1. Explain what the CPU will do in terms of functuality and configuration when executing the C source code below: unsigned char value = 0x91 1) BSR = 5; 2) BSRbits.3 = 1; 3) INTCONbitsTMR0IE = 1; 4) INTCON2bitsTMR0IP = 1; 5) TRISB = 0x00; 6) PORTB = 0x00; Please can...
  7. P

    Need help interpreting this C (programming) Code

    // Program to categorize a single character that is entered at the terminal #include <stdio.h> int main (void) { char c; printf ("Enter a single character:\n"); scanf ("%c", &c); if ( (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ) printf ("It's...
  8. S

    MATLAB code for Aldous-Broder algorithm from spanning trees of a graph

    Homework Statement Let G = (V,E) be a graph with vertices V and edge set E. Aldous-Broder algorithm: Input: G = (V,E) Output: T = (V, W), where W is a subset of E such that T is a spanning tree of G. Let W be the empty set. Add edges to W in the following manner: starting at any...
  9. D

    LaTeX Entering Code in LaTeX Documents

    How can I enter code in Latex documents?
  10. thekey

    MATLAB Please I need a Help with matlab code (Controlling the LEGO NXT Using MatLab)

    Hi Controlling the LEGO NXT Using MatLab What are my mistakes in this code ??! COM_CloseNXT all clc clear handle = COM_OpenNXT(); COM_SetDefaultNXT(handle); COM_CloseNXT(handle); NXT_GetBatteryLevel(handle); COM_CloseNXT(handle); COM_CloseNXT all clc clear...
  11. H

    Dc off-set Analysis - Maatlab code

    Hi, I am trying to use Matlab to analyse this raw signal by introducing Dc-offset analysis: I used the following code : a = [1 , -0.98]; b = [1,-1]; y = filtfilt(b,a,x); figure plot(y) And the result : But, I am trying to get a final result similar to the last graph...
  12. C

    Why is this simple output so difficult to code in C

    1 1 2 1 1 2 1 2 1 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 I am stumped on how to do this, is it really as easy as it looks?
  13. C

    Fortran Wanted: Ancient Fortran FFT source code

    Hi. I'm new here and wasn't sure which forum to post this request on, but this one seemed a good start. I am developing a talk/seminar on dealing with legacy code. In the late 1990s I was working for a large corporation in a software capacity and one day idly wondered what the source code...
  14. S

    LaTeX Cannot compile equation in LaTeX- Help with code please

    Hello! I have been trying to get this equation to work in my LaTeX document, I do not really see any issues with it so if somebody could give some guidance that would be really helpful. Code: \begin{equation} {\bf{R}} = \sum_{i=1}^{N}_{{\bf{u}}_{i}} \end{equation} Thank you
  15. B

    [MATLAB] Making code faster/more efficient

    A is a sparse matrix. B is a vector. I have the following code: for j=1:N B=A*B; end; This part of the code is inside a function which gets called about 160000 times. I ran the Profiler and this part is the bottleneck. How can I make it more efficient?
  16. R

    MATLAB What is the error in running Newton's Method in Matlab for a specific function?

    I've been using this for a Newton Approximation in Matlab function x = Newton(f, fp, x, nmax, e) % f is an inline function which we apply Newton's method on % fp is an inline function that is the derivative of function f % x is the initial guess of the root % nmax is the total number...
  17. perplexabot

    Java Debugging Java Quicksort Code: Tips and Tricks for Optimal Results

    Hi all. I am currently working on quicksort and have written the following code and gives "almost" good results. I am not too fond of the data structure I have chosen but it is too late for me to change. Lesson learned. Can anyone help me debug this thing. I have been at it for a while. Anyway...
  18. E

    MATLAB Where is my mistake in this MATLAB code?

    Hi, I am trying to plot the AN product sec II.C in the attached paper as: clear all clc s=0.5; w=0; d=5; f=0:20; NdB1=(17-30.*log10(f)); N1=10.^(NdB1./10); NdB2=40+20*(s-0.5)+26.*log10(f)-60.*log10(f+0.03); N2=10.^(NdB2./10); NdB3=50+7.5*w^0.5+20.*log10(f)-40.*log10(f+0.4)...
  19. Q

    Fortran Fortran code for geometry of fcc

    Hi friends . is there anybody here who can give me a fortran code for describing fcc lattice and give us the neighbours of each site and also which pay attention to periodic condition ? thank you for your help my friends.
  20. S

    Why isn't my algorithm code working?

    I have to write a program validating credit card numbers using Luhn's algorithm. I am having trouble getting my last function to work. For a credit card number I'm supposed to double every second digit from right to left, and sum them (note double digits, like 10=1+0), and then add the rest of...
  21. K

    Palindrome in C (Please try my code)

    Homework Statement Make a code that can check if one or many words are palindromes. The Attempt at a Solution I can't get my compiler to work so I wrote my attempt in a note document. Please can you check if it works and if it doesn't give me some guidence.. I have put a lot of time...
  22. V

    Solving the Heat Equation with R Code

    Hi! I have some trouble understanding this question. Could someone help me with it? Thanks! Solve the following with the explicit method from t=0 to t=0.5 with h=1/10 and with μ(=k/h2)=0.5 ut = uxx, -1 ≤ x ≤ 1, t>0 u(0,x) = cos(x), -1 ≤ x ≤ 1 u(t,-1) = u(t,1) = e-tcos1, t>0 Compute...
  23. L

    A code found in equations for superstring theory huh?

    I'm trying to understand what I have just learned. So some sort of browser based code or binary was discovered in equations for super-string theory. I have a few questions since I am very confused. If code was created by Claude Shannon in the 1940's, then how could it be in this code? Does...
  24. J

    MIPS Assembly Code - Convert instruction code to binary

    Homework Statement Write a single line MIPS assembly code as an input through the SPIM simulator console and the program will output a 32 bit MIPS machine code through the console. I'm using PCSpim to write the code. An example, I input this instruction in the console. addi...
  25. Q

    Fortran Fortran code for spins in heisenberg hamiltonian

    hi friends. i don't know how can i write a fortran code for expressing spins in Heisenberg model which have 3 dimension spin operator, sx,sy,sz? thanks for your help
  26. M

    MATLAB Matlab code natural numbers subset

    I have array of natural numbers from 1 to n. They are divided into m groups, where m*(m-1)=n. I need all m-1 elements from first group, last m-2 elements from second group, last m-3 elements from third group...zero elements from last group. For example 5*4=20: 1,2,3,4; 5,6,7,8...
  27. P

    Can any one here program code for PIC?

    having issues with programming, can some one help me write a code for a push button hobby servo control?
  28. Dembadon

    Is LOLCODE the Funniest Programming Language?

    http://lolcode.com/home I figured a few people here will appreciate it as well. :biggrin:
  29. W

    Fortran Issues with porting Fortran code

    I have a Fortran (F77) code which I used to use at my previous institution that I am having trouble with at my new job. I used to compile it with ifort on computers running Fedora (14 if I recall correctly). At my new job they don't have ifort so I have had to revert to the use of g77 (f77) on...
  30. G

    Fortran Programming trouble with fortran optimization code

    Hi everyone, I have some trouble adapting an existing fortran code for my application. In the following Module I am optimizing a value for two planes ( i = iplan one&two). In order to do that, I need to assign ten certain values from an external inp. file for each plane. I have two loops...
  31. B

    C/C++ Counting '1' Bits in Binary Blocks - Fast C++ Code

    Hi, For example, say we have the binary integer 101010 and I split it into blocks, say (1)(01)(01)(0). The size of the blocks is determined by some function. We want to count the number of '1' bits inside each of these blocks. I'm interested in a fast C++ code to do this. There are fast...
  32. K

    Fortran Fortran code conversion into Excel VBA

    Hi, I'm currently working on a project that requires me to convert a Fortran code into excel vba. There are some problems that I've stumbled into, so itll be great if someone could help out. one of it would be on how to convert a COMMON statement in Fortran to Excel VBA ( as in how would...
  33. Y

    [Fortrran] Some help with a code error: Segmentation Fault

    Hi, I am having a segmentation fault error just when I ask the code to print the value ipos in the program. However, If I change the print to the module, the segmentation fault does not appear. Could anyone can help know, why I can not transfer the variable ipos from the module to the main...
  34. I

    Fortran Fortran intrinsic functions source code

    Hi How can I see the source codes used for defining intrinsic functions in Fortran 90/95 ? e.g. what is the actual program for sqrt ? thanks
  35. F

    MATLAB Need help with matlab code for Newton-raphson ( really bad)

    The code runs but I get the wrong answers can you take a look at the code for this . ANSWERS ****************** x(1) = 1.035 x(2) = 1.086 x(3) = 0.927 ****************** clc clear F = @(x) [15*x(1)+(x(2)^2)-4*x(3)-13;... (x(1)^2)+10*x(2)^2-x(3)-11...
  36. F

    MATLAB Need help with Matlab code for gauss siedel i get errors, need imediat help

    Please I need HELP IMEDIATLY This is the error message that i get ? Error using ==> gauss_sied Too many input arguments. Error in ==> HW_14 at 23 [x_wo, cnt, x_w,cntt] = gauss_sied(xo, A, b, es, lam); clc clearC = [-8 1 -2 -20 2 -6 -1 -38 -3 -1 7 -34]; A = C(:,1:end-1); b = C(:,end);nr =...
  37. M

    Troubleshooting C Code: Segmentation Fault in GCC on Ubuntu

    the following code #include<stdio.h> #include<stdlib.h> int main (int argc, char *argv[]) { int* a; *a=1; return 0; } compiles ok, but throws "Segmentation fault (core dumped)" at runtime why is that? i'm working with gcc in ubuntu. I have been able to compile and run...
  38. S

    Fortran Solving FORTRAN Compiler Issues with Different Outputs

    Hi all ! This is a weird problem. A simple program to read a file and display it works differently when compiled with different versions of the same compiler. When I compile it as: garbageij@garbageij:~/NMA$ mpif90 exp4.f90 and run it, it gives the correct output. But when I compile it as...
  39. B

    Fortran Fortran on ubuntu using f95 code help

    I have the following code with error- I want this general flow. Errors I get are missing ')' at the do while line, syntax error on the line started with ****(not part of program added after fact) and expecting END Program statement at line end do counter=1 user_reaction =3 do while (counter...
  40. H

    MATLAB Matlab code for 2D inverse Fourier transforms

    I have written some routines that compute the 2D inverse Fourier transform, if anyone thinks that this may be useful at all then please let me know and I will gladly post the code.
  41. K

    Mathematica Mathematica: Need help to modify the code

    Hi all, I need help to edit the code so that the arrangment of the outputs match the one that Iam looking for. For instance: term[n_Integer, m_Integer] := Apply[Dot, Table[matg[[i]], {i, m + 1, n}]].hl[[m]] /; (n >= m); Subscript[lay, s_] := Sum[term[s, i], {i, s}]; In[1]...
  42. H

    Writing Finite Element Code for Structural Analysis

    Structural Analysis-Writing Finite Element Code, Dear all, I have written a code ( in fact it is a software) for 3D finite element structural analysis. While developing the code I found that assembling global stiffness matrix is quite complicated. The complication is even more when we...
  43. J

    Fortran Solving System of Equations with Fortran Code

    we have to write a code to solve system of equations by writing them in matricies (tridiagonal matrix) form ... the first step is to enter the coefficients of the variables (r1,r2,r3,...) and then the answers to the equations (b1,b2,b3,...) by using array , and print the equations in the form...
  44. L

    Troubleshooting Code Blocks: 'Hello World' Won't Stay!

    I just began a course on computer science and we're to use Code Blocks as the program to use, but I can't get the darn thing to work. The built in simple program called "hello world" is supposed to have a black window pop up that says "hello world", but the window pops up and disappears and I...
  45. R

    HTML/CSS Good html website code templates?

    I'm trying to fix up my dads website but the old version seems to have been made using some sort of WYSIWYG editor so the code is completely senseless and complicated. So I think it would be quicker to start and just re make the website from the ground up but I haven't got the time to fiddle...
  46. M

    Fortran Compiling a Fortran 77 Code on Ubuntu

    Hi, I have a fortran 77 code, I compiled it on cygwin in windows 7 by using f77 and gfortran, and it has been working correctly. I should use this code on Ubuntu, so I installed f77, gfortran and gcc compiler. I tried to comile that code by using f77 but it gave me the following error: > f77...
  47. J

    Mathematica Help in Mathematica code for solutions expansion of differential equations

    I need to NDsolve four differential equations. But I find my code does not work. Who can give me some suggestions? Thanks!
  48. D

    C/C++ C++ help- my code reads from small files but not large

    Hello, I'm trying to make part of a code that reads a csv file with data containing the date and time, and the wind speed at that time, then does various output things. When I copy and paste 1000 entriesinto a csv file and ru it, it works great, but if I use the file that's about 6,000kb it...
  49. J

    (15,11) Hamming Code, too work out how to calculate check digits

    Homework Statement I need to figure out how to find out the amount of check digits in a (15,11) hamming code. I know the amount of check digits is four and the amount of information digits is 7 but I don't know how to figure out how to get the answer, I only have the answer. Homework...
  50. N

    Fortran Fortran code error: forrtl: severe (66)

    Hi everybody, I have old Fortran code, originally written in the mid 1970's for an Elmer system. The code has been adapted through the years, last run successfully in 2009. The code has now landed on my lap after having been "retired" due to obsolescence. I am a pure Fortran beginner...
Back
Top