Solved


Select every other element of a vector
Write a function which returns every other element of the vector passed in. That is, it returns the all odd-numbered elements, s...

4 years ago

Solved


Finding Perfect Squares
Given a vector of numbers, return true if one of the numbers is a square of one of the numbers. Otherwise return false. Example...

4 years ago

Answered
fsolve yields initial guess as solution to non-linear equation
Try with this syntax clc, format long g a = 0.5; Eta0 = 100; t12 = 1e6; q = 2e-7; R = 0.001; x...

4 years ago | 0

| accepted

Answered
Unrecognized function or variable 'sims'.
Hi there. There are a couple of spelling mistakes in your code. The correct version is sym y(t) ode = diff(y)+4*y == exp(-t);...

4 years ago | 0

Answered
Soving PDE using explicit method
Hi, I have edited your code as shown below %% Case 1. Numerical solution of the PDE Ut=-Ux+Uxx-U using the explicit FDM % Wri...

4 years ago | 0

| accepted

Answered
Hold on command in ode45
You could do this. clear,clc a = linspace(0.1,0.2,10); % 'a' takes 10 values between 0.1 and 0.2 tspa...

4 years ago | 0

Answered
Why can't Matlab do the factorial of a non-integer number?
MatLab 'factorial' is coded so to work with integers only. The generalization of a factorial is the function, which is and...

4 years ago | 1

| accepted

Answered
How to remove a certain amount of repeating elements from an array
I am not sure I undestand your objective but maybe this could help A = [2 2 2 3 5 6]; A = unique(A); Which yields A = [2 3 5...

4 years ago | 0

Answered
How to convert each equation calculations into FOR Loop form
You need a 'hold on' in order to keep previous lines in the plot at each iteration. But you can do even better in this way p =...

4 years ago | 0

Answered
Problem solving a biological model by ode45
Note that the solution is not ignoring negative data, but you are plotting it using a logarithmic y-axis, reason for which it ca...

4 years ago | 2

| accepted

Answered
how to write summation in matlab
In summary: summation of a 1xN array A: sum(A); summation of all elements of a MxN array A: sum(A(:)) or sum(A,'all') (the lat...

4 years ago | 0

Answered
file path error in matlab
When you run a MatLab file, your current folder (often displayed on the left hand side) must be the one where that file is store...

4 years ago | 0

| accepted

Answered
Why variable has only 1 value after completing a cycle?
You need to index X too. X(l) Otherwise the values do not get stored in X, and you see only the last computed value.

4 years ago | 0

Answered
Why are the values in column 30 zero when it should be 0.2007? There are also entire rows with values of 0.
Following @Image Analyst, I tried to rewrite the code in this way g1 = 0.45; j = 0:0.005:1; mat = zeros(length(j)); for c...

4 years ago | 0

Answered
How to compare with the elements before and after
Your condtional statement says if abs(V_Ball(index)) - abs(V_Ball(index+1:end)) > 0 which is wrong, beacuse when index=length....

4 years ago | 0

Answered
Why am I getting Error using nargin? Tried to run the below code but only getting the error using nargin. I attempted everything
When you call ode45, you shold use the function's name (i.e. Emul). In the example above you are inputting 'Emulsion', which is...

4 years ago | 1

| accepted

Answered
How can I shuffle matrix without random matrix
Hi, MatLab offers a built-in function that computes all the possible permutations of an array. A = 1:6; P = perms(A); For mor...

4 years ago | 0

| accepted

Answered
How to code a couple ODE with nodes
The way you describe your problem looks similar to a discretization of a PDE. You could try to modify the function as follows ...

4 years ago | 0

| accepted

Answered
Unable to call my function and get an error
d = 1; t = 0:0.1:10; Kp = [0.2 2 6 15 55 105]; A = 2; h = fplothFUNC(d,Kp,A,t); semilogy(t,h); xlabel('time (hours)'); ...

4 years ago | 1

| accepted

Answered
How to take from array elements that must fulfil a specific condition?
Let's create a 1x10 array of values comprised between 0 and 1. A = rand(1,10); Let's assume you want to filter off all the val...

4 years ago | 0

Answered
What is the meaning of A (1: ,: ) in matlab
If there are three indexes specified, it makes sense only if your matrix has three dimensions. If it is actually 4x4, then A(1,...

4 years ago | 1

| accepted

Answered
How to plot multiple lines from a for loop iteration?
Try to move hold on before plot.

4 years ago | 0

Answered
How to find intersection between a straight line and a curve?
I am a bit ovewhelmed by your code, so I will give you a qualitative example instead of modifying it. x = [x1,x2,x3,___,xn]; ...

4 years ago | 1

Solved


Find Missing Number
A little problem (inspired by CodeChef) for the coffee break. A friend give you an array of size n-1 integers and these int...

4 years ago

Answered
How to plot this line and specified point
prompt = 'Time of flight? (s) '; t = input(prompt); tx = t-5:t+5; if (t <= 45) h = @(x) 15*x.^2; fprintf('Altitud...

4 years ago | 1

| accepted

Answered
When i run my code it says Unrecognized function or variable A.
You need to define A and N before passing them to the function. Try this: A = 4; N = 30; result = my_matlab_function(4,30); ...

4 years ago | 0

| accepted

Answered
Making plot markers distinct
Check this: https://it.mathworks.com/matlabcentral/answers/1643195-how-can-i-change-the-last-marker-of-a-line-to-a-different-st...

4 years ago | 1

Answered
Selecting columns that meet a condition
Try with this: A = [88 79 56; 91 89 95; 94 87 84]; threshold = 90; l = find(sum(A>threshold,1)); B = A(:,l);

4 years ago | 0

| accepted

Answered
How can I use a user input to pull a column from a timetable?
Not sure this is the most elegant solution, but it does work RawTime = [seconds(T.Time)]; prompt1 = 'Enter the EXACT name of v...

4 years ago | 0

Answered
Add an expression to the result
fprintf('The height of the image is %d\n', row) fprintf('The width of the image is %d\n', column)

4 years ago | 0

Load more