Representing data from File !

Hello Guys, I have a data in a file consists of two columns one for the arrival time and the other one for the Energy(ev).. I want to represent the data in the x-axes region so I will be able to estimate its function using kernel density function.. I am not sure how to represent the data in the x-axes though? I did once represent the data in the x-axes like a little dashes way and I used(repmat)but with this case I don't have any idea how to do so.. In this link there is an image and if you look at the x-axes you will see some dashes that are more in some area and less in another, thats exactly what I am looking for so I will be able to estimate its function later on..
Also, in my previously asked question you can see if you run it what I mean by "little dashes on the x-axes(red data))
Thank you all,

3 个评论

You've asked a lot of questions before. Which one do you mean by "previously"? Surely you do not expect us to read all your questions and guess, what you are talking about.
http://www.mathworks.com/matlabcentral/answers/4596-plot-spikes-in-matlab
If you run it you should be able to see what I mean"by the dashes in the x-axes" also, the link I put is for an image that could show you what I am expecting"only look in the dashes in the x-axes in the image"
duplicate is at http://www.mathworks.com/matlabcentral/answers/12733-plot-data-from-file

请先登录,再进行评论。

 采纳的回答

Go back to your previous post. I saw similar dash in the figure. The answer is right there. The command to draw it is line().
Sa=0:0.2:2; %if your original data is column vector, transpose it.
line(repmat(Sa,2,1),repmat([0;1],1,length(Sa)),'color','r' );
axis([0 2 0 10]);

9 个评论

The height of the vertical dash is fixed. All you need is the data for the x position. Make it the same format (1xn row vector) as Sa above and it's done! Only you know what's in your data file.
I did manage to get it by only one small problem, the lines in the axes are too long and I want it to be just short like the ones I showed in the image, however I believe it is working !
data = importdata('test1.dat');
x = data(:,1);
y = data(:,2);
n = (x).';
line(repmat(n,2,1),repmat([0;1],1,length(n)),'color','r' );
It is working now but the dashes are too long It covers the whole plot? how can I make it shorter?
Are you saying the height is fixed? my old example it was short but don't how to do it?
@Susan: This is one of the questions which you have to answer by your own. It definitely depend, on what you want to be displayed. If you want to show the values from 1.4 to 37.2, you use these limits. If you want to display all value from the file, you have to get the min and max of the values from the file.
Susan, I have the impression that you are working in a level of high confusion. An exhaustive analysis of your problems will help you to formulate better questions, such that the answer will be short and matching. Analysis means, that you split the problem into smaller parts as far as possible, that to find the minimal set of inputs for each sub-problem and the exact definition of the output. If all small sub-problems are solved exactly, the whole problem is solved.
The distinction between needed and not needed details is essential for programming. E.g. the color is not needed to simulate car dynamics, so do not waste time for handling the color in the problem descritpion. The meaning of a variable is not needed for the sub-problem of drawing a diagram - Matlab draws _numbers_ only. Of course for the complete problem the meaning of the numbers gets important again, but do not let such details confuse you (and the readers of you questions) in the sub-problem level.
@Susan: If the lines are to high, make them shorter than the height of the AXES. In Jiang's example the AXES has the height 10, the lines have the height 1. So I do not see, that the lines covers the whole plot.
OK thanks,
@Susan, you need to go back to the basics of MATLAB or programming in general. The line() command draws a line from one point to another point. In this example, it draws from (0,0) to (0,1), from (1,0) to (1,1), from (2,0) to (2,1) etc. The height is all 1. If you want to change the height, you can change the number accordingly. If you can't understand and see this, you need to go back to the basics.
Oh no, I get that and I understood it awhile ago.. Thanks !

请先登录,再进行评论。

更多回答(1 个)

Jan
Jan 2011-7-31

2 个投票

Do you want to represent the Energy or the arrival time in the X-axis? The small dashs at the bottom of the shown image represent just a binary signal versus time, e.g. the arrival times of detected signals. Therefore it is not clear, how you want the two data sets to be represented in a diagram. The small dashs with equal size simply do not match to your data.

5 个评论

I want the dashes in the x-axes to be the arrival time, the energy column is for testing purposes !!
The point is, I have many arrival times repetitive so this will highlight the fact that the intensity is more in that time than other, Is there a way, I can represent that in axes. For instance in my arrival time column, time 1.543 is repeated like 7 times, time 1.232 is repeated like 3 times, so I should have dashes related to that!!
Hope its clear now !
If the energy does not matter your question at all, mentioning it increases the confusion level only.
Do you want to draw a histogram plot? See "doc hist" and "doc histc".
set(gca, 'YLim', [0, 10])
I figured this way,I read the axes documentation and came up with this and it worked :)
a= min(n);
b=max(n);
axis([a b 0 30]);

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Computer Vision with Simulink 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by