Answered
If statement / conditional operations
(arbgrad<0) is a logical vector of the same length as arbgrad. BB3(arbgrad<0) which you try to assign it to is a ve...

9 years ago | 1

| accepted

Answered
how to find minimum number in array other than 0 and 1 ?
min( A( A > 1 ) ) seems to work fine. You don't need to and it with an A > 0 since that is implicit from A > 1. If you di...

9 years ago | 1

Answered
Problem graphing a piece-wise function in R2016a??
It is very simple when you think about it in components. You can create y piece-wise and then plot a graph as normal. e.g. ...

9 years ago | 0

| accepted

Answered
Is it possible to interpret legends differently?
Yes, when you create a legend either set 'Interpreter' when you create it or use hLegend = legend(...) to keep a handle ...

9 years ago | 0

| accepted

Answered
How do you rewrite the nested if statement as a loop?
lowLims = -1:0.1:0.9; highLims = -0.9:0.1:1; count = sum( x > lowLims & x <= highLims ); should work though I rep...

9 years ago | 0

| accepted

Answered
Get multiples item from listbox
selected_file=contents( get(hObject,'Value') ) should work. Or just selected_file = hObject.String( hObject.Value ); ...

9 years ago | 0

Answered
how to find distance between consecutive points
sqrt( sum( abs( diff( A ) ).^2, 2 ) ) There may be a builtin function that does it to, but something so simple I tend to ju...

9 years ago | 2

| accepted

Answered
How to flip a line upside down?
figure; hAxes = gca; x = [1 2 3]; y = [2 2.5 3.5]; plot( hAxes, x, y ) set( hAxes, 'YDir', 'reverse' ) % O...

9 years ago | 0

| accepted

Answered
How to convert cell into array of floating point numbers only?
splitStrings = cellfun( @(x) strsplit( x, ' ' ), myCell, 'UniformOutput', false ); vals = cellfun( @(x) str2double( x{1} ),...

9 years ago | 1

| accepted

Answered
How to Import Parameters from XML file into Matlab Workspace
xmldoc = xmlread( filename ); x0 = str2double( xmldoc.getElementsByTagName( 'x0' ).item( 0 ).getFirstChild.getNodeValue...

9 years ago | 1

| accepted

Answered
The GUID tutorial is not correct ?
str is a cell array of characters - one cell for each option in the popup. So you use { } to get the characters out of the chos...

9 years ago | 1

| accepted

Answered
How can I make the figure created by the plot function be an object?
h = plot( ... ) will return a handle to the object that is plotted, although the data in this will be the same as you gave ...

9 years ago | 0

| accepted

Answered
Automatically creating an array of variables and assigning to a function with changing number of outputs
[x, y, z] = ind2sub( [3,4], 9 ); works even though the size of the input is 2d, you just get z = 1. Likewise if you use n ...

9 years ago | 0

Answered
String select specific positions
a = [ Numbers{NumbersSelect} ];

9 years ago | 1

Answered
how can i resolve it not enough input arguments?
Pass the right number of arguments in when you call it. Don't just hit the big green 'Run' button, call it from command line or...

9 years ago | 0

| accepted

Answered
Why does my new version of MATLAB not have 'stlread' function?
stlread is from the file exchange: <https://uk.mathworks.com/matlabcentral/fileexchange/22409-stl-file-reader> I assume yo...

9 years ago | 2

| accepted

Answered
Plotting an image, how to show origin tick marks?
[0, 0] is not visible on an image axes normally. The origin is at [0.5 0.5] because the first pixel is centred at [1 1], extend...

9 years ago | 0

Answered
Different values in matrix and in the plot of image
You have to be careful with X,Y and rows, columns when indexing into a matrix. To get the value reported as X,Y you need to inde...

9 years ago | 1

| accepted

Answered
bug on sprintf?
The help suggests this if you want true integers from floats: wv=0:0.2:4; for i=1:length(wv) sprintf('%.2d', round( w...

9 years ago | 0

Answered
Keeping colorbar max and min in scatter3 during for loop
doc caxis If you set e.g. caxis( hAxes, [0 1] ) then it will stay that way. If it doesn't you can also set ca...

9 years ago | 0

| accepted

Answered
How to transfer a string input from GUI to another matlab file for processing
You have two options (well, at least). One is to use the 'source' variable instead of SEQ_2 because that is what it represent...

9 years ago | 0

Answered
How do use different colormaps for 2 plots in the same figure?
colormap( hAxes, 'hot' ) works in recent releases, where hAxes is your axes handle. I can't remember which release it was ...

9 years ago | 0

Answered
Wait bar or any indication of progress when loading a .mat file
I created my own busy cursor class for things like this (though it just changes the cursor to the windows busy cursor, with some...

9 years ago | 3

Answered
Adding an x-axis changes output of graph
Almost all plotting-related commands in Matlab come with an overload that takes the axes handle as first argument. Use it!! Do...

9 years ago | 1

| accepted

Answered
why is my program not working ?
x is a vector so x <-1 is also going to be a vector of logicals. In your case neither of your if statements returns true so y i...

9 years ago | 0

Answered
what if I need more decimal digits in calculated results ? ( e.g. 50 or 80 decimal digits )
You probably have to use the Symbolic Math Toolbox for more accuracy though I don't have this so am not familiar with its usage....

9 years ago | 0

Answered
Unit Testing: How to treat errors as failures
doc matlab.unittest.qualifications.Assumable rather than using assert in a unit test will cause the test to be filtered rat...

9 years ago | 0

Answered
Want to convert .MAT to .TXT
doc fprintf should be able to do what you want, but you'll have to put together the format specification yourself and work ...

9 years ago | 0

Answered
How do I force the output format of arrayfun() to be "short"?
lbl1 = arrayfun(@(lo,hi) sprintf('(%g,%g)', lo, hi), axlim(:,1), axlim(:,2), 'UniformOutput', 0) The help... doc sprin...

9 years ago | 2

| accepted

Answered
How can I make a video?
doc writeVideo;

9 years ago | 0

Load more