Advertisement

03.21.2007 at 03:44AM PDT, ID: 22462681
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

retrieve data from simple mathematical function; store data in vector(array)

Tags: data, from, retrieve
Hello,
I am trying to implement a function that calculates the position for a counter of a motor. I would like to store the postion values for the different times in a vector (or array?). This is the function I implemented:

void main(void)
{      
      float pi=0; //initial position; later != 0
      float a=pi;
      float vi=0; //initial velocity
      float b=vi;
      float qf; //final position
      qf=8200; //approximately 2 turns
      float c=3*qf;
      float d=-2*qf;

      float Tf=1; //final time
      float Ti=0; //initial time
      float Ts=0.01; //sampling time
      float nmuestras = Tf/Ts;
      int i;

      for (i=1;i<=nmuestras;i++)
      {
            float tiempo=i*Ts; //real time
            float t=tiempo/Tf;
            
            /*
            float *ptr;
            float pos;
            ptr = &pos;
            *ptr = a+b*t+c*t^2+d*t^3;
            */


            //pos_final(t);
            float pos;
            pos = a+b*t+c*t^2+d*t^3;
            //float pos = a+b*t+c*t^2+d*t^3;
            int k;
            pos_vector[k] = pos;//put the counter value in the array for storing counter values
            
       
            k++;

            
      }            

I get the following errors and don“t know how to get rid of them:

ompiling...
test control2.cpp
C:\datos\judith\proyecto_judith\pci 1784\test control2.cpp(18) : warning C4305: 'initializing' : truncation from 'const double' to 'float'
C:\datos\judith\proyecto_judith\pci 1784\test control2.cpp(37) : error C2296: '^' : illegal, left operand has type 'float'
C:\datos\judith\proyecto_judith\pci 1784\test control2.cpp(37) : error C2297: '^' : illegal, right operand has type 'float'
C:\datos\judith\proyecto_judith\pci 1784\test control2.cpp(40) : error C2065: 'pos_vector' : undeclared identifier
C:\datos\judith\proyecto_judith\pci 1784\test control2.cpp(40) : error C2109: subscript requires array or pointer type
C:\datos\judith\proyecto_judith\pci 1784\test control2.cpp(40) : warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
C:\datos\judith\proyecto_judith\pci 1784\test control2.cpp(40) : error C2106: '=' : left operand must be l-value
Error executing cl.exe.

test control2.obj - 5 error(s), 2 warning(s)


Do I maybe have to include libraries or introduce pointers?
Judith
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: jutzki
Solution Provided By: KelvinY
Participating Experts: 1
Solution Grade: A
Views: 4
Translate:
Loading Advertisement...
03.21.2007 at 05:28AM PDT, ID: 18763236

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
06.16.2007 at 12:28PM PDT, ID: 19299233

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
06.20.2007 at 08:44PM PDT, ID: 19330510

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080236-EE-VQP-29