이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
How to plot data contains only ones?
조회 수: 1 (최근 30일)
이전 댓글 표시
Brave A
2020년 11월 21일
Hi
How to plot data contains only ones?
I have txt file contains 1 1 1 1 1 1 only ones. and I want to represent it like
x-axis contains all user numbers
y-axis contains selected user where they represent it by : 1 ones. any suggestions to represent? bevause any time I tries I got line in the middle.
Thanks in advance!
답변 (1개)
KALYAN ACHARJYA
2020년 11월 21일
편집: KALYAN ACHARJYA
2020년 11월 21일
user_number=20;
test_data=ones(1,user_number);
plot(1:user_number,test_data);
And yes, you definitely find the straight line (horizontal), because all the values of the y-axis are the same here. To load the data from text file, you can user load function with complete filename.
댓글 수: 19
Brave A
2020년 11월 21일
Thanks for your answer, but I have those ones in text file, how to import it in your code?
Brave A
2020년 11월 21일
I don't want them in straight line (horizontal). Any suggestions to represent them?
KALYAN ACHARJYA
2020년 11월 21일
편집: KALYAN ACHARJYA
2020년 11월 21일
load('file_test.txt');
% txt ^ sample file name
bar(file_test);
Since all the values are the same, the height of all the bars will be the same.
or
load('file_test.txt');
plot(file_test,'*');
Brave A
2020년 11월 21일
What I need each '1' in y axis represent user number in x axis . so I need the line increases.
something like this.![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/421438/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/421438/image.png)
KALYAN ACHARJYA
2020년 11월 21일
편집: KALYAN ACHARJYA
2020년 11월 21일
To get such plot, the text data must be 1,2,3...or increment with any order
user_number=300;
test_data=1:300;
plot(1:user_number,test_data);
Brave A
2020년 11월 21일
no, not this is what I want. I have the text file which contains 276 ones. Is there any way to relate them with x axes values so I can get desired plot?
Rik
2020년 11월 21일
So you start of with this:
data=ones(276,1);
How do you want to determine x and y values? If you have to explain it in words?
Brave A
2020년 11월 21일
It did not works. Is there any way to relate them with x axes values so I can get desired plot?
Rik
2020년 11월 21일
You are not explaining how you are converting your data to a plot. Explain in words how you would find x and y points from your list of ones. I have no idea why you would not get a straight horizontal line. If you don't explain that, I can't help you.
KALYAN ACHARJYA
2020년 11월 21일
For example, lets say, the user number is 5
user_num= [1 2 3 4 5];
select_da=[0 0 1 1 1]; % Just random example
plot(user_num,select_da)
Rik
2020년 11월 21일
Can you share an example file? I suspect cumsum will do the trick for you, but I'm not sure, because you refuse to explain it with more words.
Brave A
2020년 11월 21일
Sure! Here is the dataset contains 1 for selected users and 0 for nonselected. Thanks in advance!
Brave A
2020년 11월 21일
I need to represent it in this way of containing 0 and 1 or only ones. Just need the reader to understand what is my results from figure.
Brave A
2020년 11월 21일
I have another data set same like this how to plot with cumsum? because it's combiened then in one line.
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
태그
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)