Answered
Add legend to for loop
Generally, it's best if you specify the plot object handle when you call legend(). Since all of your plotting code is missing, ...

5 years ago | 0

| accepted

Answered
For loop with variable
If you do this: for n=1,2,3 % do thing end It's the same as doing for n=1 2 % these do nothing but print to consol...

5 years ago | 1

Answered
Loop that pads at the top of the sinogram with 100 copies of its top row and at the bottom with 100 copies of its bottom row
Don't use a loop. If you have IPT, just do this: outpict=padarray(inpict,100,'replicate','both'); If you don't have IPT, you ...

5 years ago | 0

| accepted

Answered
How to find and print elements of a character array?
Is there some reason that you need to keep all the strings concatenated into one long character vector? Why not store them in a ...

5 years ago | 1

Answered
NAN problem in loop
Let's see. By iteration #7694, you're calculating (pi/3)^15389 Your result is going to end up infinite shortly. Once that ha...

5 years ago | 0

Answered
Putting 2 variables in an if loop
Doing direct comparison with strings isn't really going to work that way; certainly not with that syntax. A string is just a ch...

5 years ago | 0

Answered
What's the value of Ki in PD controller?
Kp, Ki, and Kd are coefficients in a linear combination. If you intend to remove one of the terms from a linear combination, se...

5 years ago | 0

| accepted

Answered
How to replace values less than ...
Assuming you have a matrix A and you want to make a copy B which has all nonpositive content replaced with NaN A=randn(100); B...

5 years ago | 1

| accepted

Answered
how to program this function
Reorient the vectors. If you're using R2016b or newer, you can do this: c = sum(sqrt((a-x').^2 + (b-y').^2),1) otherwise, you...

5 years ago | 0

Answered
Apply adaptive histogram equalization at the bottom part of the image
Something like this. inpict=imread('someparticularimage.tiff'); tophalf=zeros([799 size(inpict,2) size(inpict,3)],class(in...

5 years ago | 0

| accepted

Answered
How can i operate on every row of a matrix without using any loop?
Something like this: A=randi(9,4) B=cumsum(A,2) gives: A = 8 6 9 9 9 1 9 5 2 3...

5 years ago | 0

| accepted

Answered
Writing a user-defined function.
Well, row1=mymatrix(1,:); is the first row of a matrix, and row2=mymatrix(end,:); is the last row. And you can write a...

5 years ago | 0

Answered
Plotting problem and while loops
Something like this: % initial conditions MandM = 50; day = 1; while MandM > 0 % operate on the last element of the v...

5 years ago | 0

Answered
removing trailing zeros at the end of floating number
Assuming this is for display purposes, try something like fprintf('%6.3f\n',3.2653246546516) gives 3.265

5 years ago | 0

Answered
Plotting two columns from a matrix
nick_data =[ 3 1994 NaN 1592 3 1995 NaN 1562 3 ...

5 years ago | 1

| accepted

Answered
Proble with imnoise function
Look in $MLROOT/toolbox/images/images/+images/+internal/algimnoise.m or from the MIMT implementation (not yet published): case...

5 years ago | 0

Answered
How can I make linspace work in the case where I want to plot a function
If you want to preserve a vector, don't use it as the loop iterator. N=300; af=linspace(0.4905,49.05,N); % make the vector ...

5 years ago | 0

Answered
Urgent!! Help me to solve this error (struct contents reference from a non-struct array object )
Try specifying a delimiter: A=importdata ('CARS_Original_oocycts_BM_oocyst_data.txt',' ');

5 years ago | 0

| accepted

Answered
matrix multiple line should be the same
x = [1 2 3 4 5; 6 7 8 9 10] % replicate elements in 2x1 blocks xx = repelem(x,2,1) gives xx = 1 2 3 ...

5 years ago | 0

Answered
finding big letters and skip a line
Something like this: s='In the golden lightning Of the sunken sun,Oer which clouds are bright''ning, Thou dost float and run, L...

5 years ago | 0

| accepted

Answered
how to create matrix?
Something like this? node=3; mymat=1-eye(node);

5 years ago | 0

| accepted

Answered
figure view direction issue
The problem you're having is improper correspondence between your axes. I think you're presuming that the loop is a known good ...

5 years ago | 1

| accepted

Answered
How to save each column in E drive of computer?
Consider the simple example: A=rand(500,10); % placeholder data for f=1:size(A,2) outname=sprintf('output_%06d.mat',f); % ...

5 years ago | 0

| accepted

Answered
how can I Compute the value of d for the following values of x , Outcome equation d=((34.63/x)-5.126)/2.54
I have no idea what that code is intended to do, but if you just want to evaluate the expression all x: x=[0.1000,0.1500,0.2000...

5 years ago | 1

Answered
Strange behavior of if statement
It's correct. The sum isn't 1. It's approximately 1. d = [0.4 0.1 0.1 0.1 0.1 0.1 0.1]; % leading zeros for readability, pls ...

5 years ago | 0

Answered
Gaussian filters returned by fspecial() with asymmetric size parameter
I suppose I can't answer the motivation/utility question, but I can say that imgaussfilt() uses gaussian kernels that accept vec...

5 years ago | 0

| accepted

Answered
Three-dimensional lower triangular Matrix
Not sure if this is what you're asking, but: A = randi(89,10,10,2)+10; % test array mask = tril(ones(size(A,1),size(A,2))); % ...

5 years ago | 0

| accepted

Answered
Can someone suggest the best way to plot a directional 2D equilateral triangle?
This is incomplete, but it should be a start. r=10; % triangle radius p0=[0 0]; % prior point [x,y] p=[50 50]; % current po...

5 years ago | 0

Answered
I am wondering if this a no output no input function. If it is not what type of function is it?
It certainly doesn't have any input or output arguments, but reading the file with imread() is redundant if using that syntax wi...

5 years ago | 0

Answered
Remove specific values from array
Something like this: A = [9,1,2,5,1,2,5,1,1,5,2,3,1,2,5,1,2,5,4,1,2,5,10] % input x = [1,2,5,9,10]; % values to keep B = A(is...

5 years ago | 1

| accepted

Load more