For loops Definition and 23 Threads
-
Python How do for loops work in python?
str1="hello" for stringElement in str1: print("str1","=",stringElement) Strings are arrays in python and they are represented like this. Now I want to understand how the for loop is working here. My dry run-: for h in str1 print h for e in str1 print e and so on till...- shivajikobardan
- Thread
- For loops Loops Python Work
- Replies: 5
- Forum: Programming and Computer Science
-
B
Motional EMF for loops of wire vs conducting plates
I'm in an intro E&M class, and I'm trying to distinguish between Motional EMF for loops of wire and conducting plates. This question might be kind of silly, but are Eddy currents pretty much the same thing as induced currents in a loop of wire? More specifically, what I am trying to ask is if...- baseballfan_ny
- Thread
- Conducting Eddy currents Emf For loops Joule heating Loops Motional emf Plates Wire
- Replies: 9
- Forum: Mechanics
-
W
Java Java: Which Term determines this is a Sum?
Hi all, I have the code below with a 'for' loop. I see the output is 17, the sum of all elements of the (variable?) result. I am a bit confused: I cannot tell which part of the code is used to determine that the values {1,2,10,4,5} must be added to each other? Please comment/correct: 1)We define...- WWGD
- Thread
- For loops Java Sum Term
- Replies: 11
- Forum: Programming and Computer Science
-
Mathematica For looping problem not getting answer
Hi, I need some helps. I try to run the code below but its keep give me the value of intial value. Q = 1415; \[Mu] = 1000; \[Sigma] = 500; double dx; double x; double fx; double fxplusdx; double I1; double I2; I1 = 0; I2 = 0; For[x = 0, x <= Q - dx, dx += 0.01, fx = PDF[NormalDistribution[0...- hbz88
- Thread
- For loops Mathematica
- Replies: 3
- Forum: MATLAB, Maple, Mathematica, LaTeX
-
If-else statements in for loops
I've come across a rumor that states that if-else statements can make the loops go slower. Well, it's not rumors since the writer offered numbers (times) to support the statement. http://blogs.sas.com/content/iml/2012/02/13/avoid-unnecessary-if-then-statements-in-loops.html I was wondering...- ChrisVer
- Thread
- For loops Loops
- Replies: 9
- Forum: Programming and Computer Science
-
Python How Can I Improve Nested For Loops in Python for Combining Cut Expressions?
Hello, well I am not sure how to search for this online, but I raise this question here: Suppose that I have several bins of let's say cuts, here I list 3 but the main idea is to make their numbers tunable by the user: cut1 = { "p10" : "p <= 10" , "11p20 " : "10<p && p<=20" ...- ChrisVer
- Thread
- Abstract For loops Loops
- Replies: 6
- Forum: Programming and Computer Science
-
C/C++ Introduction to Data Structures in C++
In C++ we have 2 types of data structures :- 1)simple data structure so array and structure come in simple data structure group 2)compound data structure so stack,queue,link list,tree come in compound data structure group. In Indian board CBSE data structure linked list is not included it is...- sukalp
- Thread
- C++ programming Data For loops Loop analysis Structure
- Replies: 1
- Forum: Programming and Computer Science
-
Is Processing.org the Best IDE for Learning Programming?
I WANT TO ASK YOU THAT I HAVE LEARNED SCRATCH AS I AM KID OF 17 AND BEGINNER IN PROGRAMMING. I LEARN SCRATCH TO DESIGN BEFORE BUILDING,SOLVE PROBLEMS CREATIVELY. NEXT I AM LEARNING C++ AND FINDING DIFFICULTY WRITING PROGRAMS LIKE ARMSTRONG NUMBER SO I SHOULD LEARN PYTHON BEFORE C++ . I AKSED I...- sukalp
- Thread
- For loops Loop analysis Programming
- Replies: 4
- Forum: Programming and Computer Science
-
MATLAB How to get the last variable of a for loop in MATLAB
Aloha guys, I am just having trouble getting MatLab to output only the last variable of my "for loop." If anyone can help all I am looking for is an example of notation. p.s. I have done this before just not in a while and will continue to look through my old scripts and functions. just not in...- KonaGorrila
- Thread
- For loops Loop Matlab Matlab code Variable
- Replies: 2
- Forum: MATLAB, Maple, Mathematica, LaTeX
-
L
Can I use a for loop to end after entering a desired number of integers?
I'm wanting to take user input and store it into an array.There is a a minimum and maximum number of input but otherwise the user should be able to enter any number of integers in between. Say the max number is 10 but I only want to enter 5 numbers. I used a for loop but it only ends if the...- lee403
- Thread
- For loops Input Loops
- Replies: 18
- Forum: Programming and Computer Science
-
S
MHB Understanding nested for loops when decrementing
Hello! :-) I am having a hard time with understanding the logic behind decrementing nested for loops. The review problem I'm dealing with is below. This one makes the numbers go backwards. #include <iostream> using namespace std; int main(){ for (int i = 0; i < 5; i++){ for (int j = i; j >=...- smilesofmiles
- Thread
- For loops Loops
- Replies: 5
- Forum: Programming and Computer Science
-
MATLAB For Loops Homework: Solving Arbitrary Matrices
Homework Statement Homework Equations - The Attempt at a Solution I've been trying several different ways but I just can't seem to figure this one out. It seems to me like I will need nested for loops, which we haven't learned yet. The way I read the question is that this program needs to...- Feodalherren
- Thread
- For loops Loops Matlab
- Replies: 8
- Forum: Engineering and Comp Sci Homework Help
-
A
Using GOTO and For Loops in Quick Basic 64-Bit for Windows
I am working with Quick Basic, 64 Bit for Windows, which is quite good indeed, but i met again the same usual difficulties to use [do ... loop] for efficient loops. So I decided to better use [goto], as anyone else! But I also found very useful the classical for loop. Here are some useful...- alionalizoti
- Thread
- For loops Loops Windows
- Replies: 12
- Forum: Programming and Computer Science
-
A
MATLAB Matlab for loops involving matrix
Given the following system of equations 3x1 + ax2 = 1 ax1 + 4x2 = 0 where -pi ≤ a ≤ pi. We would like to find out the range of values of x1 and x2 that are observed as a is varied. Do this as follows: 1. Create a for loop that uses the variable a as the indexing value, varied from over...- aplittle31
- Thread
- For loops Loops Matlab Matrix
- Replies: 1
- Forum: MATLAB, Maple, Mathematica, LaTeX
-
K
Matlab: factorials without for loops or colon
The Problem: Write a function that finds the factorial of a positive integer without using for or while loops, the factorial function, or the : range operator. Honestly, I don't really know how to start with this one. If I were able to use a for loop it would be easy, and I don't see how I...- koryargonic
- Thread
- Factorials For loops Loops Matlab
- Replies: 2
- Forum: Engineering and Comp Sci Homework Help
-
F
MATLAB How Can I Generate a Poisson Distributed Vector Without Zeros in MATLAB?
I want to generate a Poisson distributed vector of random numbers, without any of the numbers being 0. The code I have is k = poissrnd(kmean,1,N); % where kmean is the mean of the distribution, and has been defined previously %The above generates a N by 1 vector of Poisson distributed...- *FaerieLight*
- Thread
- For loops Loops Matlab
- Replies: 1
- Forum: MATLAB, Maple, Mathematica, LaTeX
-
N
MATLAB Matlab solve function in for loops
Matlab "solve" function in "for" loops I need to solve a similar problem like shown in the below codes for a larger matrix, The 'x' here needs to be solved for each y(a,b). Each of this y(a,b) is equal to zero and 'x' will vary accordingly , so it will give a 2by 2 matrix for 'x' as well...- NJP
- Thread
- For loops Function Loops Matlab
- Replies: 4
- Forum: MATLAB, Maple, Mathematica, LaTeX
-
E
Solving 3 Non-Linear Equations with Fsolve and FOR Loops
Hi I'm using the fsolve method to solve for 3 variables in 3 non-linear equations. I would like to find out, how the 3 variables change, when I change a parameter in the 3 equations. Let's assume the parameter runs from 1 to 5 (1:1:5). The iteration looks like this: c=(1:5); for i = 1:5...- ethaniell
- Thread
- For loops Loops
- Replies: 1
- Forum: MATLAB, Maple, Mathematica, LaTeX
-
S
Solving MatLab "for" Loops With Vectors
MatLab "for" loops Homework Statement Write an m-file to evaluate y(x)= x^2 - 3x +2 for all values of x between -1 and 3, in steps of .1 . Do this twice, once with a for loop and once with vectors. Plot the resulting functions. Homework Equations The Attempt at a Solution...- sirclash
- Thread
- For loops Loops Matlab
- Replies: 3
- Forum: Engineering and Comp Sci Homework Help
-
S
MATLAB Matlab help: indexing in for loops
Hello! I consider myself typically a confident Matlab user. But I have encountered a new problem that I have no idea how to solve, so I'm hoping I can find some help. I have set up a for loop in my code to the effect of for i = 1:n if MyArray(i,1) < some value perform other...- sarawayland76
- Thread
- For loops Loops Matlab
- Replies: 4
- Forum: MATLAB, Maple, Mathematica, LaTeX
-
H
Setting up a "for loop" Eqn in Matlab for hc
Homework Statement Can someone help me set up a "for loop" for this equation I intialize hc = x0 then I have to compute hc1 = C.*(log(hc./b)+1)+ gamma.*(1-exp(-hc./gamma)) hc2 = C.*(log(hc1./b)+1)+ gamma.*(1-exp(-hc1./gamma)) hc3 = C.*(log(hc2./b)+1)+ gamma.*(1-exp(-hc2./gamma)) hc4...- Hells_Kitchen
- Thread
- For loops Loops Matlab
- Replies: 22
- Forum: Engineering and Comp Sci Homework Help
-
C
Matlab matrix selection of data using for loops and if statements ,,
matlab matrix selection of data using for loops and if statements,,,,, Hi people I was wondering if someone could assist me with the following; You received the following data values from a coworker: data = [-1.2, 3.3, 5.1, 0.2, 2.9, -0.1]; It turns out that the sensor used to collect...- curious_iza
- Thread
- Data For loops Loops Matlab Matrix
- Replies: 4
- Forum: Engineering and Comp Sci Homework Help
-
C/C++ Help with C++ for Loops & Patterns
I need some help. So far I have some for loops that print the following patters: * ** *** **** ***** ****** ******* ******** ********* ********** and ********** ********* ******** ******* ****** ***** **** *** ** * Here is the code: for(int rows=1;rows<=10;rows++) { for(int...- ranger
- Thread
- C++ For loops Loops
- Replies: 3
- Forum: Programming and Computer Science