Answered
How to put values from a for loop into an array table
Try this: BTE = [] rpm = 1800; % engine speed at condition 1 W_dot_b_cmd = 15; % engine power at condition ...

5 years ago | 0

Answered
Why do I get "Error using matlab.graphics.primitive.Text/set The property name 'num2str(k)' is not a valid MATLAB identifier" in the 'title' line of my coding?
Calling title like that sends three input arguments to title. This is not what you intend to do. You need to concatenate those t...

5 years ago | 2

Answered
How to compare terms in column and set an if loop
Here is one way to pick the minimum value from each column, with space for you to write your own additional code in case of mult...

5 years ago | 0

Answered
How to shade several areas in a plot?
Look into patch or fill, which are different ways to do basically the same thing. In addition to the x- and y-coordinates of th...

5 years ago | 1

Answered
How can I generate whiteish images with this image? This code is for example.
I don't know if this is what you have in mind, but maybe something like this: whiteness = 0.5; A = im2double(imread('fruit.png...

5 years ago | 0

Answered
How to equate two equations and find one of the unknown from it as a function of second unknown?
A little bit of algebra gives: etplusone = - et^2 + et + R1 - log(R1);

5 years ago | 0

Answered
Create a multiplication test for participants to check their level of accuracy. If they correctly answer 75% of 10 questions, they can level up in difficulty.
Take a look at this and see if it makes sense: clear all clc difficulty_level = 1; %variables for accuracy accuracy = 0...

5 years ago | 1

| accepted

Answered
convert number to string
You can use a cell array of character vectors (formerly known as a cell array of strings) to store the options. function Sex= C...

5 years ago | 0

Answered
color pixels in image
Here's an approach that may work for you. (It uses the two black-and-white images you posted to your comment here. I don't know ...

5 years ago | 0

Answered
heat equation not working
The error is because you have a typo in that line: T(i.j) should be: T(i,j) Once you correct that, you will get a new error ...

5 years ago | 0

Answered
I have a function that uses fix and rem functions but if the entered number is big it does not give the right number.
This problem is due to the nature of finite-precision floating-point numbers. In this case, since you know (presumably) that an...

5 years ago | 0

Answered
how to insert zeros row to matrix to n position
A = [1; 2; 3; 4]; % 4-by-1 matrix A n = 5; % number of rows to extend A to A(n) = 0; That's probably the easiest way. When ex...

5 years ago | 1

Answered
How to plot the letter M one line at a time
x = [1, 1, 5, 9, 9]; y = [0, 10, 5, 10, 0]; % make an animatedline with one point first: h = animatedline(x(1), y(1), 'Colo...

5 years ago | 1

| accepted

Answered
Reading certain columns of data bigger than a number into one array smaller into another
Here is the code you posted: clc; flist = dir(['./*.dat']); namelist = {}; for i = 1:length(flist) currentname = flist(...

5 years ago | 1

| accepted

Answered
Need help with the animation for my horse racing game
The error happens because of this line: for i=f f is a column vector, and when you use a column vector in a for loop like this...

5 years ago | 0

Answered
Need guidance for write Kelvin and Ramberg and Osgood
gamma = tau_0./G.*(1-exp(-t./t_bar)); G = G_0./(1+alpha.*abs(G./G_0.*gamma_a./gamma_t).^(r-1));

5 years ago | 1

| accepted

Answered
Generate Gaussian RV?
my_mean = 0; my_variance = 10; x = randn(1,n)*sqrt(my_variance)+my_mean;

5 years ago | 0

| accepted

Answered
How can I store the scalars in array after loop
Change this: for i=1:size(x) to this: for i=1:numel(x) because size(x) returns a vector of the sizes of x in each dimension,...

5 years ago | 0

| accepted

Answered
How to store values for each of the iterarions and plot the values of xr(roots) against the number of iteration?
Your while loop is overwriting the value of iter and xr each time. If you want to keep those values from each iteration (for sub...

5 years ago | 0

| accepted

Answered
Trying to run a photometry program but I keep getting an error I don't quite understand
offx(14) is -197. startyS2 is 142. So startyS2+offx(i) is -55 when i is 14. So that line is trying to index images starting at r...

5 years ago | 1

Answered
How to calculate hurst index in matrix data?
Notice this line (the end; corresponding to the for i=1:120): end; `...

5 years ago | 0

Answered
filling between two curve by patch
Change your patch command to this: patch([X1; X2(end:-1:1)], [Y ;Y(end:-1:1)], 'B', 'EdgeColor', 'none'); Reversing the X2 and...

5 years ago | 0

| accepted

Answered
How do i evaluate a matrix in row by row case?
Maybe something like this is what you want: Dist_type = {'Kernel', 'Gamma', 'Normal','Weibull'}; for j = 1 : numel(Dist_type) ...

5 years ago | 0

| accepted

Answered
Removing zeros that may be in columns or rows, in efficient fast way
X(:,~any(X,1)) = []; % remove columns which are all 0 X(~any(X,2),:) = []; % remove rows which are all 0 or an equivalent but ...

5 years ago | 0

| accepted

Answered
how to vectorize a parameterized surface
The warning is because funx and funy are using the matrix operation * rather than the element-wise operation .* (funz is ok - al...

5 years ago | 1

| accepted

Answered
How can I assign an empty value to a variable without getting the error "Unable to perform assignment because the left and right sides have a different number of elements."
find requires at least one input argument, so I would expect the code as posted to generate an error on the line where find() is...

5 years ago | 0

| accepted

Answered
how to confusion image by sin-cos map?
At some point in your for j=1:s loop, y(j+1) becomes negative, so in the next iteration r is complex. This is the source of the ...

5 years ago | 0

| accepted

Answered
how can i plot this discrete function in MATLAB
First you have to define what values of n to calculate C_n for. I will use 0 to 10: n = 0:10; Now you can calculate C_n. First...

5 years ago | 2

| accepted

Answered
New to coding, is there a way to loop a if-else if statement, or have a system check in real time?
Like this? line_color = [0 0 0]; while true status = track_line(line_color); if ~status break ...

5 years ago | 0

Answered
Xticklabel to split into two lines
Maybe this will work: set(gca(),'XTickLabel',{'Concrete' 'Masonry' 'Steel' sprintf('Steel/concrete\\newlinecomposite')});

5 years ago | 2

Load more