Your function Vout is not using the "time" argument at all!
And your plot is not using R3 at the abscissa, so you get all constant values.
How should Vout change dependent on the time?
Maybe you have to define R3 as a function of t ....
In this example I assume a linear relationship between time and resistance R3
And here an exponential relationship between time and resistance R3
Your function Vout is not using the "time" argument at all!
And your plot is not using R3 at the abscissa, so you get all constant values.
How should Vout change dependent on the time?
Maybe you have to define R3 as a function of t ....
In this example I assume a linear relationship between time and resistance R3
And here an exponential relationship between time and resistance R3
All variables are depending on time...
Your first answer is good, I mean that with linear relationship between time and resistance R3.
I was thinking at 2 for loops, something like that:
In this way I think if I will have 3, 4, or more variables that I need to iterate then maybe will be more easily to add another for loop, but I do not know exactly at this moment if this way is possible and a good way
Unless you want the two variables to 'iterate' independently from each other (which would result in a 3D surface plot) you have to specify in which way one variable should relate to the other and this is done by defining functions.
A (IMHO bad) alternative would be to provide t and R3 as equal length (!!) vectors
Ranges are to be used in three occasions only:
1) To index the elements of vectors and matrices
2) as the independent variable in a 2D XY-plot (and there is only ONE independent variable in a 2D XY-plot)
3) in a program when you use a for-loop
I am not sure about vectorization operator: look at Vout...I did not put vectorization operator above Vout (as you did) and I can still see plot of Vout. Should be this case without vectorization operator? I am not sure if I understand correctly then when is needed to use vectorization operator and where is not needed to use vectorization operator...
When an operation is not defined (and/or does not make sense) for vectors, Prime applies implicit vectorization automatically.
This is the case in your expression where you divide the vector R3 by the vector R3+R1. There is no such thing like division defined for vectors, so Prime, instead of throwing an error (which would be justified) applies vectorization on its own.
IMHO it makes sense and is good style to apply vectorization manually whenever you want vectorization to be done and don't rely on Prime doing it automatically.
You also can avoid errors which may occur when you edit an expression and suddenly you get wrong results because implicit vectorization is not applied anymore.
Find out yourself why the results without and with vectorization are different in the following example: 😉
Here is another example:
Concerning your function Test():
1) The function arguments R2 and time are useless because you redefine those variables immediately in the program, so they could be omitted
2) Your function has no explicit return value(s), so it would return just the last value calculated, which rendres all the loop senseles
3) The outer loop which uses time as iterator has no effect because variable time is nowhere used inside the loop.
Its like
where R is assigned ten times the very same value (which is independent from iterator "i")
4) The inner loop which uses R3 as iterator calculates at different value each time but the calculated value is stores every time in he very same variable Vout, overwriting the value which was assigned in the previous run.
5) The outer loop iterates 151 times, the inner one 94 times (last value would be 70 Ohm, not 68 Ohm because you use a stepwidth of 10 Ohm). So if it would work, how did you imagine that these 151*94 calculated values would be returned by your program? Which data structure? A 151x94 matrix? A 14194x1^vector (which order of the values)? Your program dos not even make an attempt to store those values and return them...
How to select first value and last value from below?
I tried with Matrix index:
I tried with Matrix row:
I tried applying matrix column first then matrix row:
@Cornel wrote:
How to select first value and last value from below?
You don't!
What you do is a misuse of ranges! I wrote in an answer above where ranges should be used and this is non of the three cases.
Try to assign what you calculated to a variable ( X:=Vout(....) ) and you will see that you get an error.
What you see as result of your function Vout may look like a vector but it isn't. Its not even a range, in fact, its an invalid object.
A range, by the way is not a vector but rather kind of an implicit loop. So there are no individual values which you could address.
If your goal is to create a vector of voltage values using the function Vout, then you have to define "time" as a vector and call the function vectorized. Then result will be a vector which you can assign to a variable and where you can address the first and last value using the usual methods.
Yes, but you did not showed how you did it. How you defined time. I followed Werner's suggestion and it works this way:
But I am not sure if you did in this way or in other way.