Answered
Can somebody help me with this script?
iscell checks if you have a cell array. uigetfile will return a cell array if multiple files are selected, otherwise it wi...

8 years ago | 0

Answered
Passing workspace variable to matlab App Designer
<https://uk.mathworks.com/matlabcentral/answers/284140-call-an-mlapp-with-input-argument-s This thread> gives a workaround for t...

8 years ago | 1

| accepted

Answered
Write a function to calculate the area of a circle
It isn't obvious from point 4 if it is expected that you just output -1 if any input is negative or -1 in only that location, bu...

8 years ago | 0

| accepted

Answered
Does "mex" function require a specific toolbox?
mex only requires base Matlab, no additional toolboxes.

8 years ago | 0

Answered
[DEPRECATED] What frustrates you about MATLAB?
Most frustrating thing for me at the moment is at times Matlab starts endlessly beeping at me with the error sound. At first I ...

8 years ago | 0

Answered
How to choose divisible numbers for a data?
doc factor will give you prime factors. You can take it from there to decide your own factors.

8 years ago | 0

Answered
how to convert a single row matrix into a number (double)
a = [1 2 3 4 5]; str2double( strrep( num2str( a ), ' ', '' ) ) works, but I'm sure there are more elegant or robust ways...

8 years ago | 0

Answered
Fitting to a homemade function
x = lsqcurvefit(@(D, xData) MyFun( a, H, D, xdata ),ydata ) should work, I think...

8 years ago | 0

Answered
Selection of greater than or less than symbol in app
I would just use a single if statement to get your operand as a string and convert it to a function handle, e.g func = ...

8 years ago | 1

| accepted

Answered
GUI elements locations has changed position
If you are using GUIDE there is an Object Browser in the View menu that allows you to gain access to every component, even if it...

8 years ago | 0

| accepted

Answered
For loop ranging from negative to positive integers?
Just create an array of e.g. inputVals = -12:20; Then use indices in your loop: for i = 1:numel( inputVals ) A...

8 years ago | 1

Answered
How can I make mlint return all the variable names in my .m-file?
You should just be able to use e.g. ismember( 'Energy', T.Properties.VariableNames ) ismember( 'Power', T.Properties.Var...

8 years ago | 1

Answered
The variable in a parfor cannot be classified, parfor
Something similar to this should work (it gives no M-Lint warnings at least) num_col = 1000; days_simulation = 400; S...

8 years ago | 0

| accepted

Answered
I want a MATLAB code that will resize a given image into 25x25 image using multiple images from a folder
If you have the Image Processing Toolbox then doc imresize should work fine. Use a loop if you want to do it for 649 im...

8 years ago | 0

Answered
imagesc: how to set NaN as white color
doc colormap allows you to define whatever colourmap you want. You can tag a white point on the front of e.g. a Parula colourma...

8 years ago | 2

Answered
how can i make figure longer on the x-axis and y-axis
doc pbaspect doc daspect both affect data plotting aspect ratio, if that is what you are asking, but you didn't really a...

8 years ago | 0

Answered
How to set axis of a plot to correspond to their values.
doc pbaspect doc daspect can be used to control the aspect ratio of the plotting area and the data. Also axis eq...

8 years ago | 0

| accepted

Answered
Assigning multiple variables vectors from a cell array
[a1, a2, a3, a4] = cellArray{:}; It is not advisable generally to do this, but for the record, that syntax should work. Ha...

8 years ago | 1

Answered
How can i find the position of nearest number "x" in a matrix "a"
[~,pos] = min( abs( a - x ) ); nearestNum = a( pos );

8 years ago | 0

Answered
How to plot a given signal but by setting a limit on the X value
doc xlim will change the axis limits someArray(1:200) will allow you to only access the first 200 samples of the ar...

8 years ago | 0

| accepted

Answered
Retrieve constant property from class handle reference
myClass.myProp will give you the constant property, you don't need an instance of it. ref = @myClass is a function ...

8 years ago | 0

Answered
How to round a result to 1 decimal place.
Which version of Matlab do you have? round( data * 10 ) / 10; is a fairly standard alternative.

8 years ago | 1

Answered
ignore spesific values in my plot
x=[-0.13*pi:0.01:0.13*pi]; x = setdiff( x, 0 ); would be one way. Just creating x in the first place without it contain...

8 years ago | 1

| accepted

Answered
Matrix calculation to find the average value
D = A + B + C works fine and is surely obvious?! mean( D ) will then give you the result you want, although your nu...

8 years ago | 0

Answered
How do I make the theta-axis or x-axis change color?
hAxes.XAxis.Color = 'b'; will, for example turn the x axis of an axes handle, hAxes, blue. Obviously you can use an RGB tr...

8 years ago | 0

Answered
Implementing listener and callback, infinite loop
Personally I always use addlistener syntax when adding a listener. I am not familiar with your syntax, but it seems it will sti...

8 years ago | 0

| accepted

Answered
Index exceeds matrix dimensions error after code finishes
Use strcmp, not == when testing equality of strings. e.g. if strcmp( Code( counter ), 'Y' ) ... end

8 years ago | 0

Answered
Search specific numbers in column
badRowIdx = find( results( :,6 ) == 1 ); results( badRowIdx, : ) = []; should remove these lines.

8 years ago | 0

| accepted

Answered
How to count count number of times change occured
v1 = [0 0 1 1 1 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0]'; v1Delta = [0; diff( v1 )]; v1ChangeCount = v1Delta; v1ChangeCount( v...

8 years ago | 1

Answered
How to extract RGB values of each pixel from an image?
r = im(:,:,1); g = im(:,:,2); b = im(:,:,3); assuming img is an RGB image of n*m*3 size, for any n, m

8 years ago | 0

Load more