Tagged Questions

The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
0answers
22 views

A question about conditional replacement [duplicate]

{g[x, y, z], h[x, y], f[]} /. (f_[t___] /; f != List) :> Plus[t] Why is the output of this expression ...
1
vote
1answer
58 views

Modifying a list of matrices with conditional statement

I have a list of around 100 matrices, that looks like this ...
4
votes
2answers
97 views

Weird behavior of conditions when using OptionsPattern and OptionValue

I'm trying to define a function that is evaluated differently depending on its options. This code ...
7
votes
2answers
108 views

using memoization with conditional statement

I would like some advice about the use of memoization in conjunction with conditional statements. Let me try to explain my problem: I am constructing a function depending on a number of parameters. ...
0
votes
2answers
63 views

Use conditional expression inside With

I want to assign a number to an internal variable, depending if a specific option has been given, but it seems to fail. Something like: ...
1
vote
1answer
59 views

Counting number of trues in If condition inside a For loop [closed]

I want to count number of trues in an If condition inside a For loop of some 10k iterations. I will be happy if you suggest me some command.
3
votes
1answer
64 views

How can I create a set (list) provide a kind of rule/algorithm?

Example: S = {r ∈ Q : r² < 2} Let S be the set of all rational numbers whose squares are less than 2. It follows that 1 ∈ S, 4/3 ∈ S, but 3/2 doesn't ∈ S because 9/4 ≥ 2. Thank you.
23
votes
5answers
2k views

2D random walk within a bounded area

I want to simulate a random walk on two dimension in a bounded area such as a square or circle. I am thinking of using If statement to define a boundary. Is there a ...
3
votes
5answers
183 views

Creating a conditional table

I'm trying to create a conditional table. Let's say I want to have such result: {1,2,3,4,5,0,0,0,0,0}. The idea is to create a table of n elements (10 in a given example), but when one element takes ...
1
vote
4answers
140 views

Minimum and maximum values under conditions

Let's create some sample data ...
0
votes
0answers
39 views

How to correctly use PatternTest (?) [duplicate]

This works fine: {3, -5, 2, 7, -6, 3} /. x_ /; x < 0 :> 0 (*{3, 0, 2, 7, 0, 3}*) and this works fine: ...
0
votes
2answers
46 views

Multiply value if it includes a period

I download data from an online source, now I have a problem: the source code doesn't allow to differ between values of 10 (which actually stands for 10) and 10.000 (which is 10'000, but Mathematica ...
4
votes
1answer
121 views

Multiple down-values with exactly the same lefthand side

I was working on an answer to this question, when I was sidetracked by what I bring up here. I wanted a function, which when given a string representing a binary number, would convert the string to a ...
0
votes
0answers
47 views

Making sense of output of Assuming/Refine

I have a conditional statement as output: ...
3
votes
1answer
97 views

Why does pattern test not work in this case to restrict the function parameters?

I was looking at this Q&A about using pattern test (pattern_?test) vs pattern condition (pattern_/;cond) and came across ...
13
votes
1answer
337 views

Quick way to use conditioned patterns when defining multi-argument function?

I have a simple function that is supposed to only accept numeric values (i.e. complex/real numbers and constant symbols e.g. Pi, E). $$f(a,b,c)=a+b+c$$ Edit: I should have chosen a less simple ...
4
votes
4answers
565 views

Skip other If conditions

I'm trying to write a code to "random" move in a matrix but it can't go to a certain position if it has a certain value (in this case I'm using the number 2). How do I make it to skip all other If ...
5
votes
2answers
115 views

What is the syntax to conditionally suppress plotting in version 9?

In Mathematica 7 it is very easy to conditionally suppress plotting of individual lines using If: ...
0
votes
3answers
78 views

Half kth term if n is even and k=n/2?

I am trying to write a function which will perform the equation in the attached image. So far, I have: ...
0
votes
1answer
30 views

How to use more/less black textcolor in function of the value of numbers in a table?

A few weeks ago, I viewed in the Mathematica Documentation any page withmultiple examples using diferent styles dpending on the value of the number in position (i,j), but I can´t remember... and I ...
1
vote
3answers
125 views

Initialize table in a Module but Break if criteria not met

I am initializing a table inside a function as follows: f[a1_, a2_, a3_] := Module[{RM = Table[a1+a2+a3+i1, {i1, 1, 10}]}, Plus@@RM] I am calling the function ...
0
votes
0answers
17 views

Make ConditionalExpression go away [duplicate]

I have a conditional expression like this, coming from an integral (can't post what it is here, because it's from a HW assignment): ...
1
vote
3answers
121 views

Where Statement

Is there a "parallel" way to perform these operations? Indices = {} For[i = 1, i <= Length[w], i++, If[w[[i]] < 0, AppendTo[Indices, i]]] Which gives a ...
0
votes
1answer
51 views

Resolve a conditional expression including exists and forall

I don't know the Resolve function exactly, especially when involved with Exists and ForAll, ...
0
votes
2answers
137 views

Replace matrix with conditions

I want to replace the values of 1. in slot under the condition that the year and month in basevalue and ...
6
votes
2answers
226 views

Flow/graph-based programming in Mathematica?

Is it possible in Mathematica to write a program inside a graph? For example if you have a bunch of different If[] statements that you need to embed within one ...
2
votes
3answers
153 views

Join matrix based on conditions

Given the following matrix: ...
3
votes
1answer
39 views

Table doesn't replace inside conditionals (If, Which) [duplicate]

This: Table[If[cond, y], {y, 1, 3}] outputs this: {If[cond, y], If[cond, y], If[cond, y]} The ...
5
votes
2answers
192 views

How to “ReplaceAll” using a set of conditional expressions instead of a list of rules [closed]

Suppose that I have two linear functions f[x_] := f0 + f1 x g[x_] := g0 + g1 x and a (possibly rather complicated) set of conditional expressions, obtained ...