Answered
Storing multiple values of output in one variable
You forgot to index |f| in your loop. %your code: for i =1:1:10; f = y*p(i)/(1+y); end %working code: ...

8 years ago | 0

Answered
conditional adding of elements to an array
Not the most beautiful code I've ever written, but this should do what you want. I tested it as well with [0 50]. a=[2 2 4 ...

8 years ago | 0

Answered
how to find index of duplicate values in a matrix ?
This code should do the trick: A = [1 2 3 ; 4 2 3]; vals=unique(A(:)); a=cellfun(@fun,num2cell(vals),repmat({A},numel...

8 years ago | 2

Answered
How to find out mm on dicom images
The |ReconstructionDiameter| field contains the width of your image in mm (at least for CT), |PixelSpacing| should contain the h...

8 years ago | 1

Answered
String X-axis for bar plus line plot
You need to explicitly set the |XTick| property as well. To rotate the labels, you can use the |XTickLabelRotation| property.

8 years ago | 0

| accepted

Answered
How to take sum of grey value of an image
IM=imread('image.png'); %IM=mean(IM,3);%convert RGB to grey IM=rgb2gray(IM); sumval=sum(IM(:)); You forgot to atta...

8 years ago | 1

Answered
How to save the name of a variable and a folder using -printf?
You can do this with |eval|, but you shouldn't. Use a cell array instead. (I have taken the liberty of adapting some of <http...

8 years ago | 0

| accepted

Answered
How to process and plot the data from the .txt files when the filenames rae not sequential?
You can use |dir| to generate a file list and apply any sort order you wish. list=dir('Cyprus*.txt'); Edit: the code b...

8 years ago | 0

| accepted

Answered
How to create a piecewise function using if and else statements?
Or without a loop: x=-5:5; y=NaN(size(x));%pre-allocate to NaN so you notice it if some values are outside all your cond...

8 years ago | 1

Answered
Do calculations for certain hours in a 3D array
You can use the |hour| function to get the submatrix with logical indexing. temp=A(:,:,hour(date_vec)==8); mean_val=sum(...

8 years ago | 0

| accepted

Answered
How to align properly using sprintf?
Using a fixed-width font will help if you're trying to align text with numbers of characters.

8 years ago | 0

| accepted

Answered
How to combine repeated same value to a single value or variable
You can use <https://www.mathworks.com/help/releases/R2017b/matlab/ref/unique.html#btb0_85 |unique|>.

8 years ago | 1

Answered
How to save a figure with slider into a .fig file?
No. You'll have to include the .m file. It might even be an idea to use the .m file to generate your figure from scratch. If you...

8 years ago | 0

| accepted

Answered
hello, I am trying to evaluate an equation for L=0.5:0.1:3, α=0:0.1:1 and n=1:1:400. I am not sure how to use nested for loop for this.
You can use |mesgrid| to create arrays to calculate every unique combination of L, alpha and n. as far as I know, Matlab can onl...

8 years ago | 0

| accepted

Answered
Find mean and standard deviation of a plot.
If you have the underlying data, you can use the |mean|, |std|, |skewness| and |kurtosis| functions.

8 years ago | 1

Answered
Determine the point where the slope is '0' on a histogram
You should fit a distribution first, so then you can be more confident about your result. In this case, it looks like simply usi...

8 years ago | 0

| accepted

Answered
how to import a text file in to matlab
You should use the |fileID| variable, as that is the handle to your file. You didn't define |test1.txt| as a variable of class, ...

8 years ago | 0

| accepted

Answered
Finding index to minimum values in 3D array
The |isequal| function thinks the code below works. A=rand(10,8,3); [a,b]=min(A,[],3); indexToMinIn3rdDim = NaN*o...

8 years ago | 0

| accepted

Answered
1 if true, 0 if false: analyzing data from excel with text condition
Another possibility of what you might mean is the code below. This also shows how intuitive logical indexing can work. Note that...

8 years ago | 0

Answered
Round date and hour to the previous 15 minute interval
Dateshift would be a good solution, but it can only shift to quarter years, not quarter hours. The code below is a way around th...

8 years ago | 2

| accepted

Answered
Rotate 1 by N vector
You mean something like this? v=1:10; v2=imrotate(v,45);

8 years ago | 1

Answered
How to adjust the code to work with 3D stack of images?
When you have problems with dimension, you should use the debugger to go through your code line by line and check in the Workspa...

8 years ago | 0

| accepted

Answered
Find Max value with index
Your current code doesn't return a maximum value for each group. The code below should do what you need. groups=[1 2 2 1 3 ...

8 years ago | 1

Answered
Error using randi (first input must be a positive integer scalar value)
As the error message said, the values must be integers in increasing order. Your original code did not have the correct order, a...

8 years ago | 0

| accepted

Answered
growning data storage after each loop
Do you mean something like the code below? I'm assuming this is a small example and not your actual code, so I didn't bother opt...

8 years ago | 0

| accepted

Answered
Calculate average change % in a group
The <https://www.mathworks.com/help/releases/R2017b/matlab/ref/unique.html |unique|> function should help you out here.

8 years ago | 0

Answered
change x,y,z axes position in a 3d plot graph
You can use the <https://www.mathworks.com/help/releases/R2017b/matlab/ref/axis.html#inputarg_limits |axis|> function with a 6...

8 years ago | 0

Answered
Could anyone help me to solve the issue
You need to save the handles to the line objects (i.e. the output of |plot|) in an array. Then you can re-order that array as yo...

8 years ago | 0

| accepted

Answered
How can i put my matlab application online?
You shouldn't <https://www.mathworks.com/matlabcentral/answers/386563-how-can-i-put-my-matlab-application-online double-post>. ...

8 years ago | 0

| accepted

Answered
ECG signal in my GUI
If you don't want to use those functions, you'll have to generate an image, which will be very slow. A good idea might be to ...

8 years ago | 1

Load more