Answered

How to find the time of event?

For this sample matrix: >> matrix = [cumsum(10*rand(25,1)), rand(25,1) < 0.1] matrix = 2.6774 0 3.9889 ...

How to find the time of event?

For this sample matrix: >> matrix = [cumsum(10*rand(25,1)), rand(25,1) < 0.1] matrix = 2.6774 0 3.9889 ...

12 hours ago | 0

| accepted

Answered

How to check an array for its content?

It sounds like you want to make sure isnan and isempty do return 0. Also, there is no need to explicitly check if the result of ...

How to check an array for its content?

It sounds like you want to make sure isnan and isempty do return 0. Also, there is no need to explicitly check if the result of ...

12 hours ago | 0

Answered

Reverse the Colormap of Surf plot

Grab the colormap and flip it upside down: f = figure; surf(peaks(50)) colormap(f, flipud(colormap(f))) colorbar

Reverse the Colormap of Surf plot

Grab the colormap and flip it upside down: f = figure; surf(peaks(50)) colormap(f, flipud(colormap(f))) colorbar

12 hours ago | 1

| accepted

Answered

Findpeaks: find the interpolation points for the width with the x axis

After you call findpeaks, you could obtain a handle to the current axes, find the handle(s) to the yellow horizontal line(s) whi...

Findpeaks: find the interpolation points for the width with the x axis

After you call findpeaks, you could obtain a handle to the current axes, find the handle(s) to the yellow horizontal line(s) whi...

13 hours ago | 0

Answered

How can i see if the value occurs in an array for the first time?

Try one of these. condition = ~ismember(loadp(i),loadp(1:i-1)); % or condition = find(loadp==loadp(i),1) == i; They should b...

How can i see if the value occurs in an array for the first time?

Try one of these. condition = ~ismember(loadp(i),loadp(1:i-1)); % or condition = find(loadp==loadp(i),1) == i; They should b...

22 hours ago | 0

| accepted

Answered

How to count the number of "" true "" and ""false"" in matrix

How to show a message "True is 66.7%" fprintf('True is %.1f%%\n', 100*TRUES/numel(a));

How to count the number of "" true "" and ""false"" in matrix

How to show a message "True is 66.7%" fprintf('True is %.1f%%\n', 100*TRUES/numel(a));

22 hours ago | 0

Answered

"1D" scatter plot without x-axis

If you only have one-dimensional data but you want to display it on two axes, you'll have to tell MATLAB where (i.e. if you have...

"1D" scatter plot without x-axis

If you only have one-dimensional data but you want to display it on two axes, you'll have to tell MATLAB where (i.e. if you have...

1 day ago | 0

| accepted

Answered

Keyboard Function Not Responding

Add a drawnow before your pause(.01) to flush the graphics queue. Or use a longer pause, but of course that messes with the ani...

Keyboard Function Not Responding

Add a drawnow before your pause(.01) to flush the graphics queue. Or use a longer pause, but of course that messes with the ani...

1 day ago | 0

Answered

"Invalid second data argument" error while using "plot" function (Lagrange Interpolation)

You are correct, it is complaining because pointy1 is a function handle. You can obtain the output of pointy1 when evaluated at ...

"Invalid second data argument" error while using "plot" function (Lagrange Interpolation)

You are correct, it is complaining because pointy1 is a function handle. You can obtain the output of pointy1 when evaluated at ...

1 day ago | 1

| accepted

Answered

how to plot a vector

Vsw is a scalar, so nothing will show when you plot it. You are overwriting the value of Vsw in each loop of your for loop. Do y...

how to plot a vector

Vsw is a scalar, so nothing will show when you plot it. You are overwriting the value of Vsw in each loop of your for loop. Do y...

3 days ago | 1

Answered

cannot fill table with chars?

x=[1;2;3]; y=[4;5;6]; T=table(x,y); T.words = repmat({''}, 3, 1); % this creates a 3x1 cell array After these lines, T.words...

cannot fill table with chars?

x=[1;2;3]; y=[4;5;6]; T=table(x,y); T.words = repmat({''}, 3, 1); % this creates a 3x1 cell array After these lines, T.words...

3 days ago | 0

| accepted

Answered

Plot: x axis and y axis values with commas as 1000 separators

You can format the tick labels using the TickLabelFormat property of the axis. For example: ax = axes('YScale','log'); plot(ax...

Plot: x axis and y axis values with commas as 1000 separators

You can format the tick labels using the TickLabelFormat property of the axis. For example: ax = axes('YScale','log'); plot(ax...

3 days ago | 0

| accepted

Answered

Saving data in a FOR loop

Does this work? n=2:50; b = zeros(numel(n),1); for i = 1:numel(n) a = (t_r>=Tvec(n(i))-dt/2) & (t_r<Tvec(n(i))+dt/2); ...

Saving data in a FOR loop

Does this work? n=2:50; b = zeros(numel(n),1); for i = 1:numel(n) a = (t_r>=Tvec(n(i))-dt/2) & (t_r<Tvec(n(i))+dt/2); ...

6 days ago | 0

| accepted

Answered

How can I export text and numeric data from excel to uitable (GUI element)

According to the docs, when you set the Data property of a uitable created with the figure function, you must set it to a numeri...

How can I export text and numeric data from excel to uitable (GUI element)

According to the docs, when you set the Data property of a uitable created with the figure function, you must set it to a numeri...

6 days ago | 0

Answered

cellfun vs. varfun applied to column of table

varfun passes entire variables from your table into your function. It calls your function once per table variable. The variable ...

cellfun vs. varfun applied to column of table

varfun passes entire variables from your table into your function. It calls your function once per table variable. The variable ...

7 days ago | 1

| accepted

Answered

rotate colorbar tick labels

You could place the labels yourself using text. Personally, I'd rather MATLAB figure out the placement. Here's code which puts ...

rotate colorbar tick labels

You could place the labels yourself using text. Personally, I'd rather MATLAB figure out the placement. Here's code which puts ...

7 days ago | 0

Answered

transform fprintf in disp

Maybe this? disp(sprintf('\nPara i= %d\n e a= %f e a resposta Ã©: %f ', i, n, c)) You'll get a warning that fprintf is prefe...

transform fprintf in disp

Maybe this? disp(sprintf('\nPara i= %d\n e a= %f e a resposta Ã©: %f ', i, n, c)) You'll get a warning that fprintf is prefe...

7 days ago | 0

Answered

Adding Legend to a multiple graph within a loop

The legend should show after you call legend(), i.e.: clear all close all clc hold on data=dlmread('data.txt') for i= 1:27...

Adding Legend to a multiple graph within a loop

The legend should show after you call legend(), i.e.: clear all close all clc hold on data=dlmread('data.txt') for i= 1:27...

8 days ago | 0

| accepted

Answered

assume(x^2 == y) doesn't work

From the docs, "assume is not additive. Instead, it automatically deletes all previous assumptions on the variables in conditio...

assume(x^2 == y) doesn't work

From the docs, "assume is not additive. Instead, it automatically deletes all previous assumptions on the variables in conditio...

8 days ago | 0

Answered

Histogram with adjusted bins to gaussian

If you'd like to fit a histogram to a normal distribution but you don't know the underlying data (e.g. you've altered the histog...

Histogram with adjusted bins to gaussian

If you'd like to fit a histogram to a normal distribution but you don't know the underlying data (e.g. you've altered the histog...

11 days ago | 0

Answered

MATLAB drawrectangle ROI custom wait function difficulty

Store the figure in h so that when you later call close(h), MATLAB knows what h is: h = figure(1);

MATLAB drawrectangle ROI custom wait function difficulty

Store the figure in h so that when you later call close(h), MATLAB knows what h is: h = figure(1);

12 days ago | 0

| accepted

Answered

How to edit grid lines on a 3D plot

It seems to me that Dillen.A's answer from your link is pretty elegant. Adapting that code to work with 3D axes: f = figure; ...

How to edit grid lines on a 3D plot

It seems to me that Dillen.A's answer from your link is pretty elegant. Adapting that code to work with 3D axes: f = figure; ...

12 days ago | 0

Answered

Matlab Sort Command Output

How about this? x1=3; x2=1; x3=2; a=[x1 x2 x3]; varNames = {'x1','x2','x3'}; [~, idx] = sort(a); fprintf('Output:\n%s\n',...

Matlab Sort Command Output

How about this? x1=3; x2=1; x3=2; a=[x1 x2 x3]; varNames = {'x1','x2','x3'}; [~, idx] = sort(a); fprintf('Output:\n%s\n',...

13 days ago | 1

Answered

Compare elements from two matrix.

How about this? x = x1; idx = abs(x1) < abs(x2); x(idx) = x2(idx);

Compare elements from two matrix.

How about this? x = x1; idx = abs(x1) < abs(x2); x(idx) = x2(idx);

13 days ago | 0

| accepted

Answered

Subscript indices must either be real positive integers or logicals.

thetat=0:0.012566:0.6283; for idx = 1:numel(thetat) % use thetat(idx) to access the appropriate theta value in any iterati...

Subscript indices must either be real positive integers or logicals.

thetat=0:0.012566:0.6283; for idx = 1:numel(thetat) % use thetat(idx) to access the appropriate theta value in any iterati...

13 days ago | 0

| accepted

Answered

Value assignment to vector, without loop

Here's an option: N = 20; idx = (1:N)'; out = (idx >= frm & idx <= to)*value'; The indices in frm and to can't overlap, and ...

Value assignment to vector, without loop

Here's an option: N = 20; idx = (1:N)'; out = (idx >= frm & idx <= to)*value'; The indices in frm and to can't overlap, and ...

14 days ago | 1

| accepted

Answered

How do you display a users input into an questdlg command?

fprintf prints text to a file which corresponds to the supplied file ID or, if you don't supply a file ID, the command window (f...

How do you display a users input into an questdlg command?

fprintf prints text to a file which corresponds to the supplied file ID or, if you don't supply a file ID, the command window (f...

14 days ago | 0

| accepted

Answered

How can i prevent the plots from appearing while still using them as frames for the movie function?

Plot your frames on a figure whose Visible property is set to 'off': fig = figure('Visible', 'off'); ax = axes(fig); x = lins...

How can i prevent the plots from appearing while still using them as frames for the movie function?

Plot your frames on a figure whose Visible property is set to 'off': fig = figure('Visible', 'off'); ax = axes(fig); x = lins...

15 days ago | 0

Answered

Vectors must be the same length with plot of Shear Force Diagram

If you look in the workspace, you should see that X has length 200 while V has length 101. If you want to plot V over X, they ne...

Vectors must be the same length with plot of Shear Force Diagram

If you look in the workspace, you should see that X has length 200 while V has length 101. If you want to plot V over X, they ne...

15 days ago | 0

| accepted

Answered

subplot question - with image and plot

This is possible by setting the parent axes in your call to imshow: subplot(1,2,1); plot(rand(10,1)); ax = subplot(1,2,2); i...

subplot question - with image and plot

This is possible by setting the parent axes in your call to imshow: subplot(1,2,1); plot(rand(10,1)); ax = subplot(1,2,2); i...

15 days ago | 0