Answered
Why am I getting negative seconds when subtracting clock times?
You could use: tic %at start of trial DurationTrial = toc Or alternatively StartTrial = datetime('now') EndT...

7 years ago | 0

| accepted

Answered
How do I select data from one vector based upon the values of another vector?
mean(v(s==true)) And false for the opposite gender If you have more complex grouping data, then G = findgroups(s) ...

7 years ago | 0

| accepted

Answered
How can I improve the presentation of this graph?
I forgot about this question. If you are still working on it, you could try something like this: x=um_A1'; y=y_A1'; p...

7 years ago | 3

| accepted

Answered
scatter plot with different legend and color
You could use gscatter(x, y, 1:numel(x))

7 years ago | 0

| accepted

Answered
Get the equation of the graph plotted into the workspace OR how the equation can be generated explicitly ?
Let x and y be your data. Use polyfit to fit coeffecients to your data using a third order polynomial. P = polyfit(x, ...

7 years ago | 0

| accepted

Answered
Subplot not combining graphs
Do not initate a new figure prior to plotting. A subplot is a single figure with several *axes*. Simply remove figure; ...

7 years ago | 1

Answered
Matlab Histogram: connecting bin centers to make a curve
Like this? Y=randn(1000,1) hist(Y) [y,x]=hist(Y); hold on plot(x,y,'r') You could also use ksdensity to fit an ...

7 years ago | 0

Answered
How to built a 3D binary volume array from set of X,Y,Z coordinates?
Still not 100% sure what you are looking for, but you said you want to display your scattered points as a solid, so that leads m...

7 years ago | 3

| accepted

Answered
how to covert a log number into nature number?
You can get the approximate fractions using |rat|: [num,den] = rat(log(5^(1/2) + 2)/4 + 5^(1/2)/2) yields 1791/1211 whic...

7 years ago | 0

Answered
How can I convert a 2d image into a 3d one?
You could use surf to display the grayscale matrix. An example: G=imread('cameraman.tif') surf(G,'edgecolor','none') ...

7 years ago | 0

| accepted

Answered
How to replace matrix value with string from cell array?
Cell is a built in function so avoid using it as a variable name. Anyway, you can try this: mask=logical(count(cell,'#')) ...

7 years ago | 0

Answered
Longest Sequence of 1s
Here's another one %% remove blanks n= n(find(~isspace(n))); %% save all trailing ones out=regexp(n,'1+','matc...

7 years ago | 0

Answered
intersection between a dataset and a cell array
Okay, I've never worked with _datasets_ but they are quite similar to tables. %% Load data d1=load('xyz.mat'); d2=loa...

7 years ago | 1

| accepted

Answered
How do I make the second graph look like the first?
yyaxis automatically changes the linestyle and even inserts markers when plotting multiple lines. If you want to make the second...

7 years ago | 1

| accepted

Answered
How can I color a (circle) area in a scatterplot?
You could do something like, id=(U1.^2+U2.^2)<1; plot(U1(id),U2(id),'.r',U1(~id),U2(~id),'.k')

7 years ago | 0

Answered
Cell array of dates in string format to date array
The problem is that you have a number of NaNs at the end of your cell array. Due to those NaNs, you can not concatenate the data...

7 years ago | 1

| accepted

Answered
Combining multiple test results based on ID’s and categories
As previous posters already pointed out, you will want to keep your data in a table which are ideal for dealing with categorical...

7 years ago | 0

Answered
How do I make an efficient While loop? setting true = 0, then while true = 0, results in an error on the while line. of code. What is wrong with that logic?
Use == for logical operations. Also do not call your variable _true_. Writing while true=0 is very counterintuitive, as...

7 years ago | 0

Answered
Calculate the difference between adjacent pixels
Try this instead abs(diff(imageArray,1,2))

7 years ago | 0

| accepted

Answered
Ploting a graph with if else statement
Try this instead, no for loop needed fs = 100000000 dt = 1/fs StopTime = 5E-6 ...

7 years ago | 0

| accepted

Answered
Comparing two matrix per greater or equal to
arrayfun(@(x)sum(x>=B),A) or perhaps I am reading it wrong and you need to swap A for B and vice versa

7 years ago | 0

| accepted

Answered
Finding max value of a function in specific range
yn(-0.5: 0.5) This line returns the values of yn of the index in the braces. Problem is that those are not valid indices, a...

7 years ago | 0

| accepted

Answered
colorbar for specified color
Based on the data and code given below in the comments, you can build a custom colorbar with textboxes. The result is quite nice...

7 years ago | 0

| accepted

Answered
How can the colors of ones choice be added to the legends automatically in an image ?
usually when you have a 3d plot like that you use the colorbar instead of a legend. Try adding this: colormap(parula(16)) ...

7 years ago | 0

| accepted

Answered
make a contour plot with dates on x axis, time on y axis and fog concentration as z values.
As dbp said, contour is not compatible with datetime format. Here's an example with |surf|, which is quite similar. data...

7 years ago | 0

| accepted

Answered
Removing rows in a timetable that don't meet certain criteria
I suspect that you are using the wrong type of braces. Remember that TT{r,c} outputs the data in double-format while TT(r,c) ret...

7 years ago | 0

| accepted

Answered
sum up of different time series
I'm not a fan of indexed variable names, but OK. I assume the times are *exactly and precisely* defined, so that two dates in di...

7 years ago | 0

| accepted

Answered
How to get monthly average from daily data?
Not sure what you mean by "without breaking the matrix into some new matrix", but here we go: *x* is column with months, ...

7 years ago | 3

| accepted

Answered
contour plot based on xyz data
You just need to interpolate gridded data. xyz=dlmread('data_new.txt'); x=xyz(:,1); y=xyz(:,2); z=xyz(:,3); [X...

7 years ago | 4

Answered
How to create a contour plot with frequencies on the y axis and time on the x axis but with the time in hh:mm:ss format?
Try this, t is a |double| (seconds) t=t/(60*60*24); contour(t,freq,z) datetick('x','hh:mm:ss','keepticks') This...

7 years ago | 0

| accepted

Load more