@@ -119,6 +119,171 @@ void MatrixPlot::plot1d(Matrix & referenceMatrix, int subplotIndex){
119
119
120
120
}
121
121
122
+ void MatrixPlot ::plot1d (Matrix & xMatrix , Matrix & yMatrix ){
123
+
124
+ if (xMatrix .getRows () != yMatrix .getRows () && xMatrix .getCols () != yMatrix .getCols ())
125
+ cerr << "Matrizes de coordenadas incompativeis. Encerrando aplicativo" ;
126
+
127
+ int matrixPlotRows = xMatrix .getRows ();
128
+ int subplotAmount = xMatrix .getCols ();
129
+
130
+ mglData matrix_X_coordinates (matrixPlotRows );
131
+ mglData matrix_Y_coordinates (matrixPlotRows );
132
+
133
+ range matrixRange ;
134
+
135
+ float matrixDataPoint ;
136
+ for (int subplotIndex = 0 ; subplotIndex < subplotAmount ; subplotIndex ++ )
137
+ {
138
+ for (int matrixPlotRowIndex = 0 ; matrixPlotRowIndex < matrixPlotRows ; matrixPlotRowIndex ++ )
139
+ {
140
+ float x = xMatrix .getMat ((matrixPlotRowIndex + 1 ), (subplotIndex + 1 ));
141
+ float y = yMatrix .getMat ((matrixPlotRowIndex + 1 ), (subplotIndex + 1 ));
142
+
143
+ matrix_X_coordinates .a [matrixPlotRowIndex ] = x ;
144
+ matrix_Y_coordinates .a [matrixPlotRowIndex ] = y ;
145
+
146
+ //minMax x
147
+ try {
148
+ if (x < matrixRange .x_min )
149
+ matrixRange .x_min = x ;
150
+ } catch (...) {
151
+ matrixRange .x_min = x ;
152
+ }
153
+
154
+ try {
155
+ if (x > matrixRange .x_max )
156
+ matrixRange .x_max = x ;
157
+ } catch (...) {
158
+ matrixRange .x_max = x ;
159
+ }
160
+
161
+ //minMax y
162
+ //minMax x
163
+ try {
164
+ if (y < matrixRange .y_min )
165
+ matrixRange .y_min = y ;
166
+ } catch (...) {
167
+ matrixRange .y_min = y ;
168
+ }
169
+
170
+ try {
171
+ if (y > matrixRange .y_max )
172
+ matrixRange .y_max = y ;
173
+ } catch (...) {
174
+ matrixRange .y_max = y ;
175
+ }
176
+ }
177
+
178
+ this -> SetOrigin (0 ,0 ,0 );
179
+
180
+ //Subplotagem
181
+
182
+ this -> SubPlot (
183
+ this -> subplotCols ,
184
+ this -> subplotRows ,
185
+ 0 , "" );
186
+
187
+ this -> Axis ("xy" );
188
+
189
+ if (this -> autoRange )
190
+ {
191
+ this -> SetRange ('x' , matrixRange .x_min , matrixRange .x_max );
192
+ this -> SetRange ('y' , matrixRange .y_min , matrixRange .y_max );
193
+ }
194
+
195
+ this -> Plot (matrix_X_coordinates , matrix_Y_coordinates );
196
+ }
197
+
198
+
199
+ }
200
+
201
+ void MatrixPlot ::plotbox (Matrix & referenceMatrix , int subplotIndex )
202
+ {
203
+ int matrixRows = referenceMatrix .getRows ();
204
+ int matrixCols = referenceMatrix .getCols ();
205
+
206
+ mglData matrix_X_coordinates (matrixRows );
207
+ mglData matrix_Y_coordinates (matrixRows );
208
+
209
+ range matrixRange ;
210
+
211
+ float matrixData [matrixRows ][matrixCols ];
212
+
213
+ for (int i = 0 ; i < matrixRows ; i ++ )
214
+ {
215
+
216
+ for (int j = 0 ; j < matrixCols ; j ++ )
217
+ {
218
+ float dataPoint = referenceMatrix .getMat (i + 1 ,j + 1 );
219
+
220
+ if (j == 0 )
221
+ {
222
+
223
+ //Min_x
224
+ try {
225
+ if (dataPoint < matrixRange .x_min )
226
+ matrixRange .x_min = dataPoint ;
227
+ } catch (...) {
228
+ matrixRange .x_min = dataPoint ;
229
+ }
230
+
231
+ //Max_x
232
+ try {
233
+ if (dataPoint > matrixRange .x_max )
234
+ matrixRange .x_max = dataPoint ;
235
+ } catch (...) {
236
+ matrixRange .x_max = dataPoint ;
237
+ }
238
+
239
+
240
+ matrix_X_coordinates .a [i ] = dataPoint ;
241
+ }
242
+ else
243
+ {
244
+ //Min_x
245
+ try {
246
+ if (dataPoint < matrixRange .y_min )
247
+ matrixRange .y_min = dataPoint ;
248
+ } catch (...) {
249
+ matrixRange .y_min = dataPoint ;
250
+ }
251
+
252
+ //Max_x
253
+ try {
254
+ if (dataPoint > matrixRange .y_max )
255
+ matrixRange .y_max = dataPoint ;
256
+ } catch (...) {
257
+ matrixRange .y_max = dataPoint ;
258
+ }
259
+
260
+ matrix_Y_coordinates .a [i ] = dataPoint ;
261
+ }
262
+
263
+ }
264
+
265
+ }
266
+
267
+ this -> SetOrigin (0 ,0 ,0 );
268
+
269
+ //Subplotagem
270
+
271
+ this -> SubPlot (
272
+ this -> subplotCols ,
273
+ this -> subplotRows ,
274
+ subplotIndex , "" );
275
+
276
+ this -> Axis ("xy" );
277
+
278
+ if (this -> autoRange )
279
+ {
280
+ this -> SetRange ('x' , matrixRange .x_min , matrixRange .x_max );
281
+ this -> SetRange ('y' , matrixRange .y_min , matrixRange .y_max );
282
+ }
283
+
284
+ this -> Plot (matrix_X_coordinates , matrix_Y_coordinates );
285
+ }
286
+
122
287
void MatrixPlot ::setAutoRange (bool option )
123
288
{
124
289
this -> autoRange = option ;
0 commit comments