isolating certain x values for barplot from an undefined variable

조회 수: 6 (최근 30일)
Hi All,
So I'm trying to plot a bar graph with only certain values being expressed, however the values are not based on a variable that is going to be shown on the graph.
My x values would be my trialnumbers, my y values would be my fixation counts. For my x values however, I only want the values that are labelled as free ( which is another variable in my data that indicates whether the condition in my trials were either fixed or free).
Wondering if anyone knows that general code I could use to isolate the x values for the plot. Thanks!
  댓글 수: 2
dpb
dpb 2019년 9월 15일
Going to have to show what you have and what you need...can't tell enough from general description to be able to write specific code...
In general, you would use logical addressing on whatever it is that the label values are to select/reject the subset.
Veena Sanmugananthan
Veena Sanmugananthan 2019년 9월 24일
ok!
I searched up how to do that, and I was able to figure it out.
Thank you very much!

댓글을 달려면 로그인하십시오.

채택된 답변

Jyothis Gireesh
Jyothis Gireesh 2019년 9월 19일
My understanding is that you want to extract values from the “x” for which the ‘trial’ variable is free. To this end, you may use of the concept of logical indexing in MATLAB.
This concept uses a logical array to extract elements from the array. The logical array contains the logical value 1 when a particular condition is met.
In this case you make use of the following syntax to create the logical array to extract the elements from “x” using
xNew = x(Trials == free); %Assuming ‘trials’ is a string array
It may be helpful to look at the following documentation link

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by