ShinobiChart ignoring series made of 0s - shinobi

I'm using ShinobiControls for creating a simple chart. When the dataset is:
#{
#"Value": #0.0,
#"Date": #1364828400
},
#{
#"Value": #0.0,
#"Date": #1364914800
},
#{
#"Value": #0.0,
#"Date": #1365001200
}
]
I receive this error message:
Ignoring range with 0.000000 span
From: SChartNumberAxis at 0xc287030, axisRange = { 0.000000, 0.000000 }, defaultRange = { 0.000000, 0.000000 }, maxRange = { 0.000000, 0.000000 }
and my app gets stuck. No error message. Nothing.
Has anybody seen anything similar?

It seems to me that you have not set range for the axis tied to the Value dimension of your points. Supposing that value is displayed on the Y axis. Try:
SChartNumberRange *yAxisRange = [[SChartNumberRange alloc] initWithMinimum:[NSNumber numberWithInt:0] andMaximum:[NSNumber numberWithInt:10]];
SChartNumberAxis *yAxis = [[SChartNumberAxis alloc] initWithRange:yAxisRange];

Related

How to fix this on Matlab Index in position 2 exceeds array bounds?

I have this following code on my Matlab, now i am getting an index in position 2 exceeds array bounds. How can i improve it?
data = thingSpeakRead(929272, "NumMinutes", 100);
aveTemp = mean(data(:,2)); // This line is the one, i got two fields from my thingspeak channel
apiKey = 'O6P4N8AVZWKNGK5U';
alertURL = "https://api.thingspeak.com/alerts/send";
options = weboptions("HeaderFields",["ThingSpeak-Alerts-API-Key", apiKey]);
alertBody = sprintf("The temperature is %0.2fF.", aveTemp);
alertSubject = sprintf("! Temperature exceeded 60.0F!");
if avg_temperature > 60.0
webwrite(alertURL, "body", alertBody, "subject", alertSubject, options);
end

Convert SIint16 to float on iPhone4

I am developing an app which uses simple pitch perception and it runs fine in the Xcode Simulator. The app loads in the iPhone 4 and I can navigate the app but no output is shown . I have started to debug and find that when I convert Sint16 to float I get an overflow error.
I have tried vDSP and a simple loop.
simplified code n=1536
sampleBuffer = (SInt16*) malloc(n);
floatSamples = (float*) malloc(sizeof(float)*n);
// Convert SInt 16 to float
for(int i = 0; i<n; i++) {
floatSamples[i] = (float)samples[i];
}
//vDSP_vflt16(samples,1,floatSamples,1,n);
This results in
-0.000000
-0.000000
-0.000000
964957789008661674961361960960.000000
-5629971079108504200413184.000000
-inf
35116851871418647838720.000000
-inf
0.000000
0.000000
0.000000
-1233.760620
288987875649316726325339192557568.000000
-0.000000
-0.000000
-0.000000
-7508525217561044282816045485425426432.000000
-656399043038732589927376093184.000000
0.000000
-0.000053
9470091451011432448.000000
-24555002
similar result from vDSP
Everything is fine in the simulator on iPhone 4s all the vDSP calculations work.
iPhone is running ios7.1.2 and xCode 6 on MacBook pro.
Just looking for a clue really.
The code
sampleBuffer = (SInt16*) malloc(n);
allocates n bytes, not n SInt16 values.
You need:
sampleBuffer = (SInt16*) malloc(sizeof(SInt16)*n);

How to plot a 3D surface in matlab using set of data [duplicate]

This question already has answers here:
How to create a 2D-matrix out of my data for surf()?
(2 answers)
Closed 8 years ago.
I have a set of 3D data which are not ordered. I need to plot a surface which basically connects them together and color the surface based on my z values.
Here is an example of the data that I have.
-0.144847 -5.239271 -0.000000
-5.430672 -0.044747 0.000000
0.006860 0.282666 -0.000000
0.385219 0.005522 -0.000000
-6.464983 -7.105215 -0.000000
-7.028026 -4.026576 0.000000
-6.092855 -1.826723 -0.000000
-5.619010 -0.886051 0.000000
-5.769190 -0.487232 0.000000
-3.496163 -7.561789 -0.000000
-1.883844 -7.683578 0.000000
-0.845860 -6.159235 -0.000000
-0.487085 -5.865159 0.000000
-5.442694 0.346838 -0.000000
0.158343 -5.402572 -0.000000
0.075667 0.309257 0.000000
0.648079 -1.368195 0.000000
0.510721 -0.525318 0.000000
-0.749283 0.435931 0.000000
-0.338834 0.399974 -0.000000
-0.151157 0.367955 0.000000
-0.071820 0.371475 0.000000
-0.125133 -4.846842 -1.025075
-5.425106 0.058539 -0.341047
0.006806 0.282034 -0.057553
0.384929 0.005456 -0.021184
-5.890619 -6.417012 -0.339540
-6.828500 -3.837339 -0.394468
-6.048110 -1.732177 -0.362965
-5.597372 -0.822289 -0.333655
-5.815376 -0.394711 -0.360211
-3.447449 -7.345610 -0.198281
-1.883239 -7.680056 -0.098589
-0.845817 -6.153723 -0.041199
-0.487017 -5.863854 -0.019289
-5.475775 0.419626 -0.104516
0.159202 -5.400629 -0.017949
0.189255 0.205864 -0.010534
0.280893 0.151170 -0.015441
0.327987 0.090052 -0.018171
0.128256 0.272671 -0.006972
0.075667 0.309256 -0.003940
0.652881 -2.917007 -0.040059
0.647424 -1.368548 -0.037539
0.510386 -0.525737 -0.029055
0.546600 -0.273572 -0.030561
0.448142 -0.108028 -0.024821
-1.643195 0.460307 -0.102182
-0.751135 0.435615 -0.045282
-0.326989 0.388574 -0.019874
-0.151168 0.367766 -0.009394
-0.071815 0.371646 -0.004734
-0.125133 -4.846842 -1.025075
-5.425106 0.058539 -0.341047
0.006806 0.282034 -0.057553
0.384929 0.005456 -0.021184
-5.890619 -6.417012 -0.339540
-6.828500 -3.837339 -0.394468
-6.048110 -1.732177 -0.362965
-5.597372 -0.822289 -0.333655
-5.815376 -0.394711 -0.360211
-3.447449 -7.345610 -0.198281
-1.883239 -7.680056 -0.098589
I have around 400 points, like the ones above.
Thank you in advance for your help.
What format is your data in and what kind of plot do you want? Once you have separated the data into 3 variables it is simple to plot it into a 3-D scatter plot and specify the color using:
scatter3(X,Y,Z,S,C)
More info is available on the mathworks website which is SUPER useful for figuring out MATLAB

iPhone OpenGL ES1 VBO Texture Coordinate Issues

I switched my code to use VBO and suddenly my sprites (2 triangle triangle-strip) have bad texture coordinates.
Disabling VBO makes the problem go away.
Note - I align my vertex and texture coordinate data to 4 bytes as specified in this link:
https://developer.apple.com/library/ios/#documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/TechniquesforWorkingwithVertexData/TechniquesforWorkingwithVertexData.html
This is a printout of the vertex data, it goes:
x, y, z, 0.0f, tu, tv, 0.0f, 0.0f
Vertex 0 -0.500000 0.500000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000
Vertex 1 -0.500000 -0.500000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
Vertex 2 0.500000 0.500000 0.000000 0.000000 1.000000 1.000000 0.000000 0.000000
Vertex 3 0.500000 -0.500000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000
This is how I generate the VBOs:
m_numVertices = 4
m_stride = 8
glGenBuffers( 1, &m_vboVertices); // Generate our Vertex Buffer Object
glBindBuffer( GL_ARRAY_BUFFER, m_vboVertices); // Bind our Vertex Buffer Object
glBufferData( GL_ARRAY_BUFFER, (m_numVertices * m_stride) * sizeof(float), m_pVertexData, GL_STATIC_DRAW); // Set the size and data of our VBO and set it to STATIC_DRAW
glBindBuffer( GL_ARRAY_BUFFER, 0 );
glGenBuffers( 1, &m_vboIndices );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_vboIndices );
glBufferData( GL_ELEMENT_ARRAY_BUFFER, sizeof(GLubyte)*4, m_pIndices, GL_STATIC_DRAW );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
And this is how I render the sprite:
glBindBuffer(GL_ARRAY_BUFFER, m_vboVertices);
glVertexPointer( 3, GL_FLOAT, byteStride, BUFFER_OFFSET(0) );
glTexCoordPointer( 2, GL_FLOAT, byteStride, BUFFER_OFFSET(4) );
glBindBuffer(GL_ARRAY_BUFFER,0); // reset
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_vboIndices );
glDrawElements(GL_TRIANGLE_STRIP, m_numVertices, GL_UNSIGNED_BYTE, BUFFER_OFFSET(0));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0); // reset
BUFFER_OFFSET is defined as:
#define BUFFER_OFFSET(i) ((char *)NULL + (i))
With VBO:
Without VBO:
Thanks.
Edit - After messing around a bit with the code, it appears that this problem also occurs when drawing using GL_TRIANGLES.
It appears that the problem is that I am not calculating the glTexCoordPointer offset in bytes. It should be:
glTexCoordPointer( 2, GL_FLOAT, byteStride, (char*)NULL + (4*sizeof(float)) );
The Macro BUFFER_OFFSET was incorrect.
Applying this fix solved the problem.

Objective C Float value is converted internally - no idea why

Am writing a game using cocos 2d which involves lot of Float type properties to determine the vertices(x,y) of my shapes (Square , Triangle). I have a Shape class which simply holds the total number of vertices(int) and the vertices (CGFloat*). I have one more class called ShapeHolder which defines the values for different types of shapes , it has the properties called Shape square; and Shape Triangle. In the ShapeHolder init am storing(hard coding) the vertices information(x,y) as follows , am also printing the values immediately after the definition which works perfectly
CGPoint _square[] = {
CGPointMake(100.0f, 100.0f) ,
CGPointMake(200.0f, 100.0f) ,
CGPointMake(200.0f, 200.0f) ,
CGPointMake(100.0f, 200.0f)
};.
square = [[[Shape alloc] initWithVerticesLength: 4] retain];
square.vertices = _square;
for (int i = 0; i< square.count; i++) {
NSLog(#"Init Square Vertices X Y = %f , %f" , square.vertices[i].x ,square.vertices[i].y );
}
triangle = [[[Shape alloc] initWithVerticesLength: 3] retain];
triangle.vertices = _triangle;
The problem am having is on while retrieving the same values in my OpenGL drawing class to render different shapes , here is the code
allShapes = [[ShapeHolder alloc] init];
for (int i = 0; i< allShapes.square.count; i++) {
NSLog(#"Main Square Vertices X Y = %f , %f" , [[allShapes square]vertices][i].x ,[[allShapes square] vertices][i].y );
}
The value is converted somehow , no idea why please clarify. Am not getting any runtime errors or compile time error which is really bothering my knowledge
Init Square Vertices X Y = 100.000000 , 100.000000
Init Square Vertices X Y = 200.000000 , 100.000000
Init Square Vertices X Y = 200.000000 , 200.000000
Init Square Vertices X Y = 100.000000 , 200.000000
Main Square Vertices X Y = 100.000000 , 100.000000
Main Square Vertices X Y = -1.998910 , 0.000000
Main Square Vertices X Y = 0.000000 , 0.000000
Main Square Vertices X Y = -1.998912 , 0.000000
Looks like you are doing a shallow copy of the array pointer for _square. You need to be doing a deep copy of the vertices into a member array in your object.
The reason your first vertex isn't being changed is that your class is keeping the pointer to the first point in the array. Subsequent vertices in the array are being reclaimed by the memory manager and reused. Possibly luck too.