Answered

Convert a vector into a matrix (row wise)

From the reshape() docs, for the syntax B = reshape(A,sz) "The elements in B preserve their columnwise ordering from A." If...

Convert a vector into a matrix (row wise)

From the reshape() docs, for the syntax B = reshape(A,sz) "The elements in B preserve their columnwise ordering from A." If...

3 días ago | 1

Answered

Combining x and y arrays and converting subsequent values

Assuming x and y are formatted like the following... [x,y] = meshgrid(1:1920,1:1080); ...then how about this? q = nan(size(x)...

Combining x and y arrays and converting subsequent values

Assuming x and y are formatted like the following... [x,y] = meshgrid(1:1920,1:1080); ...then how about this? q = nan(size(x)...

4 días ago | 0

Answered

Create matrix with different type of data and sort it based on one of its columns

For the following example: % example... A = strings(10,1); B = rand(10,1); you could use a table: % combine and sort... T ...

Create matrix with different type of data and sort it based on one of its columns

For the following example: % example... A = strings(10,1); B = rand(10,1); you could use a table: % combine and sort... T ...

5 días ago | 0

| accepted

Answered

Patch color error "Vectors must be the same length."

The docs linked by Geoff mention that you can specify an n-by-1-by-3 array of RGB values (for n number of faces). I've defined c...

Patch color error "Vectors must be the same length."

The docs linked by Geoff mention that you can specify an n-by-1-by-3 array of RGB values (for n number of faces). I've defined c...

6 días ago | 0

| accepted

Answered

How to format output to exponential notation

This should work: fprintf('At voltage = %.2E nV\n',CurData(1,C)*10^9) If you don't want the plus sign: val = CurData(1,C)*10^...

How to format output to exponential notation

This should work: fprintf('At voltage = %.2E nV\n',CurData(1,C)*10^9) If you don't want the plus sign: val = CurData(1,C)*10^...

6 días ago | 0

| accepted

Answered

How to return index of started specific pattern from array/matrix(column/rows)

See here: https://blogs.mathworks.com/loren/2008/09/08/finding-patterns-in-arrays/#7 idx = strfind(a, ex);

How to return index of started specific pattern from array/matrix(column/rows)

See here: https://blogs.mathworks.com/loren/2008/09/08/finding-patterns-in-arrays/#7 idx = strfind(a, ex);

6 días ago | 1

Answered

Change labels positions for pie chart

One option: https://www.mathworks.com/matlabcentral/answers/94801-why-do-the-pie-labels-overlap-when-the-wedges-are-very-small-...

Change labels positions for pie chart

One option: https://www.mathworks.com/matlabcentral/answers/94801-why-do-the-pie-labels-overlap-when-the-wedges-are-very-small-...

7 días ago | 0

Answered

How to fill a matrix column by column better than by a for loop?

How about something like this? xx = 0:0.1:1; nxx = numel(xx); nyy = 10; xm = repmat(xx',1,nyy); base = linspace(0,1,nyy);...

How to fill a matrix column by column better than by a for loop?

How about something like this? xx = 0:0.1:1; nxx = numel(xx); nyy = 10; xm = repmat(xx',1,nyy); base = linspace(0,1,nyy);...

8 días ago | 1

| accepted

Answered

How to make the program more flexible

Here's a function that places an M x N grid of Xs within a rectangle defined by pos, as well as a few lines which use that funct...

How to make the program more flexible

Here's a function that places an M x N grid of Xs within a rectangle defined by pos, as well as a few lines which use that funct...

8 días ago | 1

| accepted

Answered

Replacing Values in Matrix with NaN's based on Row and Column

Possibly, you could use sub2ind() to convert your rows and columns to linear indices: ind = sub2ind(size(yourMatrix), yourRows,...

Replacing Values in Matrix with NaN's based on Row and Column

Possibly, you could use sub2ind() to convert your rows and columns to linear indices: ind = sub2ind(size(yourMatrix), yourRows,...

10 días ago | 0

Answered

Get the middle point of a matrix

Possibly MATLAB's convolution functions will be faster: % 1D case: B = conv(A, ones(2,1), 'valid') / 2; % 2D case: B = con...

Get the middle point of a matrix

Possibly MATLAB's convolution functions will be faster: % 1D case: B = conv(A, ones(2,1), 'valid') / 2; % 2D case: B = con...

11 días ago | 1

| accepted

Answered

Opening a figure saved in .fig with several plots and working on them separately

You could obtain handles to each of the axes within your figure and go from there: fig = openfig('myfig.fig'); ax_handles = fi...

Opening a figure saved in .fig with several plots and working on them separately

You could obtain handles to each of the axes within your figure and go from there: fig = openfig('myfig.fig'); ax_handles = fi...

12 días ago | 0

Answered

Error When Using Writetable Function

It seems like writetable() has trouble handling the case where a variable in your table contains a cell which itself contains an...

Error When Using Writetable Function

It seems like writetable() has trouble handling the case where a variable in your table contains a cell which itself contains an...

12 días ago | 0

| accepted

Answered

Indexing a matrix in matlab according to conditions set on other matrices

Here's one way: result = (a <= 5 & b >= 6) .* c;

Indexing a matrix in matlab according to conditions set on other matrices

Here's one way: result = (a <= 5 & b >= 6) .* c;

13 días ago | 1

| accepted

Answered

Plot with intervals for x axis

I believe stairs() is what you want: https://www.mathworks.com/help/matlab/ref/stairs.html

Plot with intervals for x axis

I believe stairs() is what you want: https://www.mathworks.com/help/matlab/ref/stairs.html

14 días ago | 0

Answered

changing uislider position by script

sld = uislider(fig,... 'Orientation', 'vertical',... 'Position',[ 100 100 3 100],... ...

changing uislider position by script

sld = uislider(fig,... 'Orientation', 'vertical',... 'Position',[ 100 100 3 100],... ...

16 días ago | 0

Answered

how to define a path in saveas command

Possibly like this? pathdatasave = 'E:\matlab'; saveas(gcf,sprintf('%s%03d.png', pathdatasave, i));

how to define a path in saveas command

Possibly like this? pathdatasave = 'E:\matlab'; saveas(gcf,sprintf('%s%03d.png', pathdatasave, i));

17 días ago | 0

Answered

Disable Datatips on click

Not the greatest solution, but you could make the datatips invisible until your timer deletes them: dcm = datacursormode; dcm....

Disable Datatips on click

Not the greatest solution, but you could make the datatips invisible until your timer deletes them: dcm = datacursormode; dcm....

18 días ago | 1

| accepted

Answered

Index exceeds the number of array elements (5).

Likely a typo in line 56: As(6)=-l^2*cos(phi); %Spring node 6 % ^ should be Af? As it is, Af only h...

Index exceeds the number of array elements (5).

Likely a typo in line 56: As(6)=-l^2*cos(phi); %Spring node 6 % ^ should be Af? As it is, Af only h...

18 días ago | 0

| accepted

Answered

Why aren't my lines showing up on my graph?

Specify a marker to show scalar values. For example, a circle: plot (GT, IP, 'ro') Or are you trying to plot a range of pressu...

Why aren't my lines showing up on my graph?

Specify a marker to show scalar values. For example, a circle: plot (GT, IP, 'ro') Or are you trying to plot a range of pressu...

25 días ago | 0

Answered

Plot only adjacent points that are close to each other

logidx = abs(diff(Y)) < 0.022; dY_idx = find([logidx 0] | [0 logidx]); Y_adj_close = Y( dY_idx ); Seems to me that every part...

Plot only adjacent points that are close to each other

logidx = abs(diff(Y)) < 0.022; dY_idx = find([logidx 0] | [0 logidx]); Y_adj_close = Y( dY_idx ); Seems to me that every part...

25 días ago | 0

| accepted

Answered

Error Handling Question: How to Loop Until User Enters NUMBERS(!) in GUIDE gui edit boxes and then presses an "Update" button

Possibly, you ought to simply exit your callback function if the input is invalid? The values will then only be stored in your a...

Error Handling Question: How to Loop Until User Enters NUMBERS(!) in GUIDE gui edit boxes and then presses an "Update" button

Possibly, you ought to simply exit your callback function if the input is invalid? The values will then only be stored in your a...

25 días ago | 0

| accepted

Answered

giving color to output result

If you mean output to the command window, see this file exchange contribution from Yair Altman: https://www.mathworks.com/matla...

giving color to output result

If you mean output to the command window, see this file exchange contribution from Yair Altman: https://www.mathworks.com/matla...

26 días ago | 0

Answered

why there is only one value at my plot

Without the below period, MATLAB is performing right matrix division on two 1x151 vectors, resulting in a scalar value. t = 0:0...

why there is only one value at my plot

Without the below period, MATLAB is performing right matrix division on two 1x151 vectors, resulting in a scalar value. t = 0:0...

26 días ago | 2

Answered

How can I extract curve data from a .FIG file?

You could use findobj() on each figure to find the handles of the two lines. You can differentiate the lines by their LineStyles...

How can I extract curve data from a .FIG file?

You could use findobj() on each figure to find the handles of the two lines. You can differentiate the lines by their LineStyles...

26 días ago | 0

Answered

Options for displaying data by clicking on a marker in a plot

For R2018b and later: X = rand(10,1); Y = rand(10,1); IDs = randi(100,10,1); s = scatter(X, Y, 'x'); s.DataTipTemplate.Da...

Options for displaying data by clicking on a marker in a plot

For R2018b and later: X = rand(10,1); Y = rand(10,1); IDs = randi(100,10,1); s = scatter(X, Y, 'x'); s.DataTipTemplate.Da...

26 días ago | 0

| accepted

Answered

Operands to the || and && operators must be convertible to logical scalar values.

Use & instead for element-wise and (or | for element-wise or): whitePixels=ext_rows((150<ext_rows) & (ext_rows<200));

Operands to the || and && operators must be convertible to logical scalar values.

Use & instead for element-wise and (or | for element-wise or): whitePixels=ext_rows((150<ext_rows) & (ext_rows<200));

27 días ago | 0

| accepted

Answered

How to plot log-scale with number ?

Maybe something like this? % data: X = 2*logspace(1, 3, 100); Y = rand(100,1); % labels to keep: labels = [20 30 50 70 10...

How to plot log-scale with number ?

Maybe something like this? % data: X = 2*logspace(1, 3, 100); Y = rand(100,1); % labels to keep: labels = [20 30 50 70 10...

27 días ago | 1

| accepted

Answered

creating a new matrix without certain rows with elements below a certain value

If I'm understanding correctly, I believe your third line is enough (with the addition of a colon in the second subscript of M t...

creating a new matrix without certain rows with elements below a certain value

If I'm understanding correctly, I believe your third line is enough (with the addition of a colon in the second subscript of M t...

27 días ago | 0

| accepted

Answered

Access .mlapp data in .m file after app closes

Rather than waitfor(H), which waits until H is deleted, how about waitfor(H,propname,propvalue), where propname is some property...

Access .mlapp data in .m file after app closes

Rather than waitfor(H), which waits until H is deleted, how about waitfor(H,propname,propvalue), where propname is some property...

29 días ago | 1

| accepted