Respondida
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...

más de 7 años hace | 0

| aceptada

Respondida
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) ...

más de 7 años hace | 0

| aceptada

Respondida
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...

más de 7 años hace | 3

| aceptada

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

más de 7 años hace | 0

| aceptada

Respondida
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, ...

más de 7 años hace | 0

| aceptada

Respondida
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; ...

más de 7 años hace | 1

Respondida
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 ...

más de 7 años hace | 0

Respondida
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...

más de 7 años hace | 3

| aceptada

Respondida
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...

más de 7 años hace | 0

Respondida
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') ...

más de 7 años hace | 0

| aceptada

Respondida
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,'#')) ...

más de 7 años hace | 0

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

más de 7 años hace | 0

Respondida
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...

más de 7 años hace | 1

| aceptada

Respondida
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...

más de 7 años hace | 1

| aceptada

Respondida
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')

más de 7 años hace | 0

Respondida
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...

más de 7 años hace | 1

| aceptada

Respondida
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...

más de 7 años hace | 0

Respondida
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...

más de 7 años hace | 0

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

más de 7 años hace | 0

| aceptada

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

más de 7 años hace | 0

| aceptada

Respondida
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

más de 7 años hace | 0

| aceptada

Respondida
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...

más de 7 años hace | 0

| aceptada

Respondida
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...

más de 7 años hace | 0

| aceptada

Respondida
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)) ...

más de 7 años hace | 0

| aceptada

Respondida
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...

más de 7 años hace | 0

| aceptada

Respondida
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...

más de 7 años hace | 0

| aceptada

Respondida
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...

más de 7 años hace | 0

| aceptada

Respondida
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, ...

más de 7 años hace | 3

| aceptada

Respondida
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...

más de 7 años hace | 4

Respondida
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...

más de 7 años hace | 0

| aceptada

Cargar más