2010/4/27 John W. Eaton
<address@hidden>
On 27-Apr-2010, Judd Storrs wrote:
| 2010/4/27 Carn Draug <carandraug.ml@gmail.com>:
| > if (interval)
| > final = input;
| > else
| > final = end;
| > endif
|
| How about:
|
| final = length(data):
The length function is a bit strange because for non-empty arguments,
it returns the size of the largest dimension, not the overall length.
For empty arguments, it returns 0. This odd behavior is inherited
from Matlab and is required for compatibility.
Instead of using length, I'd recommend using size to get the size of a
specific dimension, or numel for the overall number of elements.
I don't really have a specific size that I can define easily at this step. I have a bunch of arrays (1 column, several rows) whose size will be variable every time I run the code. There's also a switch block to define which of them is gonna be ploted so in some cases, I'll be using one array and in some others I'll be using other who will have a different size.
Here's the code if it helps too see the rest. There's an array of structures data with several fields and I'll be plotting a specific field from each of the array. The interval is not there because I haven't figured how to do it yet.
colors = {"black", "red", "green", "blue", "magenta", "cyan"};
iColor = 1;
for i=1:numel(data)
switch model
case 1
plot (data(i).raw_times, data(i).raw_frap, "color", colors{iColor});
hold on;
axis ([0 data(i).raw_times(end) 0.4 0.9])
case 3
plot (data(i).bin_times, data(i).PD_fit, "color", colors{iColor});
hold on;
axis ([0 data(i).bin_times(end) 0.4 0.9])
case 4
plot (data(i).bin_times, data(i).FM2_fit, "color", colors{iColor});
hold on;
axis ([0 data(i).bin_times(end) 0.4 0.9])
case 5
plot (data(i).bin_times, data(i).FM3_fit, "color", colors{iColor});
hold on;
axis ([0 data(i).bin_times(end) 0.4 0.9])
otherwise
error("Unknown model for graph_maker %g", model)
endswitch
iColor++;
if (iColor > numel(colors))
iColor = 1;
endif
endfor
title(top)