Need some help with matlab
Need some help with matlab
(OP)
I am having a page full of data which comes from the sensor readings...which i have to scan through my program and check to see if there are any changes.. but my initial issue is that i need to write a function in matlab which takes the file which contains the data and gives an output saying that there are changes in the reading.. or there isnt any.. as i am quiet new to matlab i am running out of ideas as to how to do it...
.. i would also like an advice on how to scan a matrix and compare the value with the value which is in the same column but the previous row. i know to do it in c.. but it is giving me a hard time in matlab.. please help me if anyone knows the answer to it...
Regards,
Capzos :)
.. i would also like an advice on how to scan a matrix and compare the value with the value which is in the same column but the previous row. i know to do it in c.. but it is giving me a hard time in matlab.. please help me if anyone knows the answer to it...
Regards,
Capzos :)





RE: Need some help with matlab
TTFN
RE: Need some help with matlab
The way to do your second question is similar to C++ valarray slices, only maybe a little easier.
You could loop through all of your new columns and test against your previous old columns (this is just a repeat of your question unless I misunderstood it.)
There are more details needed, this is only non dunctional psuedo code.
load oldData
load newData % Assume only one column bigger, rows the same
[r_, c_ ] = size( newData );
for iColumn = 2 : c_
indexDifferent = find( newData( :, iColumn ) ~= oldData( :, iColumn - 1 ) );
if ~isempty( indexDifferent % if it is not empty do something important
(
% do something
)
end
RE: Need some help with matlab
thanks for your help... here a bit more detail....
it is a data of 8 columns and 1000,s of rows.. but the columns are constant (8).. and it will be in the normal .txt format and quite huge.. sometimes the rows extending to 10000 lines...the main prob is that i have to do it using only matlab.
please see if u could find a way out.
capzos
RE: Need some help with matlab
Try this:
[ nRow, nColumn ] = size( newData );
derivatveOfData = diff( newData ); % works on a column
indexChangeIndicator = find( abs( derivatveOfData ) ) > 0 );
columnOfChange = 1 + floor( indexChangeIndicator / nRow );
rowOfChange = 1 + indexChangeIndicator - floor( indexChangeIndicator - columnOfChange * nRow );
Now you know what row has a new pice of changed data byt the vector rowOfChange. If you want to know exactly what column was different, you would use the columnOfChange vector.note that the +1 for the columnOfChange was becuase of the floor function producing a zero and MATLAB using 1 based indexing. But the +1 for the rowOfChange was because the diff function produces a vecor one shorter than the original data and I thought you would want to know the index into your original data matrix.
RE: Need some help with matlab
thanks for the help again.. one good solution i found was using the inbuilt find function. i have done some code optimization. find can directly get the rows and columns.. so i modified it like this
[ nRow, nColumn ] = size( newData );
derivatveOfData = diff( newData )
[mRow, mColumn] = find(derivatveOfData)
FYI,
changing it to round instead of floor in columnOfChange worked.. but the rowOfChange gave wrong values.. so i went hunting for some solution and found the deeper use of find.
Enough for today.. will come up with somemore problems tomorrow..
Thanks a lot,
Regards,
Capzos
RE: Need some help with matlab
RE: Need some help with matlab
when i use the save option in matlab, the answers that is saved is in floating point format for e.g, 5.7600000e+002 8.7690000e+003 1.7540000e+003 6.7700000e+002.. but i want it in the normal integer format like 5760 8769 1754 677 .... the command i am using is save myData.txt myData -ascii.... could u please help me out of this... coz its convinient to anlyse the data int the normal format...
thanks,
capzos
RE: Need some help with matlab