2

While running one of my programs, I need to scan through a rather large matrix (100*700) to identify irregularities.

My initial idea was to have a breakpoint in place when I need to do a data scan, but I'm not a fan of that solution.

What I'm looking for would be equivalent to calling openvar('A') during a function call (except I can't presently do that). The alternative, disp renders the matrix poorly.

Any hints?

Edit:
A sample example of what I'm trying to do:

function main

time = 0:pi/100:4*pi;
inV = (1:100)';

data = 10*diag(rand(100,1))*sin((inV)*time);

error = ceil(350*rand); % find the anolmaly
data( ceil(100*rand),error:(error+20))= -13;
test = true;

openvar('data')

while test

    close all;
    figure(1)
    hold on;
    plot(data')

    test= (input(strcat('Further review? ')));
    if (test)
        data(test,:) = [];
    end
end

If I used a breakpoint, I could scan through the data knowing that -13 is wreaking havoc on it (-13 is some random number I used, in reality, it's far more complicated). However breakpoints only exist during the current Matlab session.

I'm using Matlab 2012a

Robert Seifert
  • 25,078
  • 11
  • 68
  • 113
Rasman
  • 5,349
  • 1
  • 25
  • 38
  • I don't know if this helps, but you can pause the execution using `pause on; pause` after having plotted your matrix with `image()`. Plotting your matrix with image is the easiest way to analyse it I think... – reverse_engineer Jul 10 '12 at 07:19
  • Why aren't you a fan of the breakpoint solution? – Sam Roberts Jul 10 '12 at 10:16
  • @user1241315 I do plot the matrix when I need to scan through my matrix. The pause solution is not much better then my other solution, which is to use `input`: at most I'll see 64*64 – Rasman Jul 10 '12 at 10:35
  • @SamRoberts breakpoints don't seem to save after I close Matlab is the biggest problem I have – Rasman Jul 10 '12 at 10:39
  • @Rasman Ok, indeed input is a good way to hold execution, and what is the problem then? You do use `image()` to plot the matrix? Then you should be able to check your matrix easily and I don't see what's the problem you have left... – reverse_engineer Jul 10 '12 at 11:22
  • @user1241315 well it doesn't work, which is why I'm posting this question. See edit. – Rasman Jul 10 '12 at 12:04
  • @Rasman Have you tried this? Create a startup.m and a finish.m file (on your path). In the finish.m file, save your breakpoints by typing s = dbstatus, and saving s to a mat file. In your startup.m file, load the mat file and reset the breakpoints with dbstop(s). – Sam Roberts Jul 10 '12 at 12:14
  • @SamRoberts that will only work for my machine on this OS. If I give it someone else, he's gonna have some problems. That's why I'm looking for an alternative. (sorry if my previous post sounded harsh, that wasn't my intention) – Rasman Jul 10 '12 at 12:24
  • @Rasman Ok well plot your matrix with `imagesc(data)` before the input command and you'll be able to identify easily where the data equals -13. Now of course if what you have to do is harder, maybe it won't work... What exactly do you have to identify? – reverse_engineer Jul 10 '12 at 12:40
  • 1
    Instead of breakpoints you can use the `keyboard` command. – Yanai Ankri Jul 10 '12 at 12:50

2 Answers2

1

Ok so what I'm looking for is

t = uitable;
set(t,'Data',data)

nice and simple

Rasman
  • 5,349
  • 1
  • 25
  • 38
0

(1) you can use DISP(NUM2STR(DATA,FORMAT)) or FPRINTF to render the matrix more properly, but displaying a 100x700 matrix is really not a good idea.

(2) You are using Matlab, so I think Matlab should to the job of finding irregularities in a Matrix for you. What is the point of using Matlab if you do such a job by hand. I suggest to find the irregularities in your matrix with an algorithm (You could provide some details about the irregularities, maybe somebody will come up with an idea about how to do that).

georg
  • 635
  • 7
  • 16