How to write this equation within Matlab?

  • Context: MATLAB 
  • Thread starter Thread starter hurryon
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary

Discussion Overview

The discussion revolves around writing specific equations and code snippets in Matlab, particularly focusing on a mathematical equation involving expected values and uniform distributions, as well as a binary weighted current steering DAC design. Participants seek assistance with coding and clarifications on Matlab functionalities.

Discussion Character

  • Homework-related
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant presents an equation involving expected values and asks how to implement it in Matlab.
  • Another participant questions whether all quantities in the equation are scalars, leading to clarification that while E{T} and E{L} can be vectors, other quantities are scalars.
  • A suggestion is made to use a specific Matlab code snippet for calculating E{T} based on the provided equation.
  • Further inquiry is made about implementing a uniform speed distribution in Matlab, with a suggestion to use the rand() function for generating random values.
  • Another participant provides a reference to Matlab's built-in help for generating uniform values, demonstrating how to use the rand() function correctly.
  • A separate participant asks for help with a different Matlab code related to designing a binary weighted current steering DAC, indicating that their current code is not functioning as expected.

Areas of Agreement / Disagreement

Participants generally agree on the use of Matlab functions and coding practices, but there is some confusion regarding the nature of the variables involved in the initial equation. The discussion regarding the DAC design remains unresolved, with no consensus on the correct implementation.

Contextual Notes

Some participants express uncertainty about their Matlab expertise and seek confirmation on coding practices. The discussion includes varying levels of familiarity with Matlab's functionalities.

hurryon
Messages
9
Reaction score
2
Homework Statement
Hi, guys. I've been reading a paper including some equations. Now, I'd like to write one equation as codes in Matlab. The equation is as following:

E{T} = (ln(v_max / v_min) / v_max - v_min) * E{L}

where E{T} is the expected value of transition time and E{L} is the expected value of transition distance. Also, v_max and v_min mean the maximum speed and the minimum speed, respectively. Note that the speed is a uniform speed distribution within [v_min, v_max].

Thanks in advance.
 
Last edited:
Physics news on Phys.org
Are all these quantities scalars?

- Warren
 
Yes, they are all scalar values. However, E{T} and E{L} can be vectors.
 
Then they aren't all scalars.

Do something like this

Code:
EL = [ 1 2 3 ]
v_min = 1
v_max = 2

ET = (log(v_max / v_min) / (v_max - v_min)) * EL

- Warren
 
Thanks for your kind reply. Could you provide one more? The speed values (v_max and v_min) are in a uniform speed distribution within [v_min, v_max].

How do I write that in Matlab? Shall I just use rand() ? (I just want to confirm from others because I'm not an export within Matlab)

Thanks in advance.
 
You're aware that Matlab has excellent built-in help, right?

Code:
>> help rand
...
Generate uniform values from the interval [a, b].
           r = a + (b-a).*rand(100,1);

If you just want one random number, use:

Code:
v = v_min + (v_max - v_min) * rand();

- Warren
 
Thanks. As you mentioned, Matlab has an excellent help system and I know about that. Sorry, I might annoy you (I just want to get the certain reply from Matlab experts).

Anyway, thanks again!
 
hw to design current steering binary weighted dac in matlab

Hi, anybody can u pls suggest homework to design the dac using binary weighted current steering method in matlab.

thanks
 
How to write this code in Matlab?

M0=100;
var0=100;

for i=1:478
for j=1:448
if(temp(i,j)>M)
G(i,j)=M0+sqrt(double((var0*power((temp(i,j)-M),2))/V));
else

G(i,j)=M0-sqrt(double((var0*power((temp(i,j)-M),2))/V));

Where temp(i,j) is an matrix. This code is not working. I am getting the values of G as 100. Please help me with the correct code. I am new to matlab.
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
4K
Replies
3
Views
2K
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 2 ·
Replies
2
Views
5K
  • · Replies 3 ·
Replies
3
Views
7K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K