Answered
How to remove rows from an array where there is a 1 in a logical array of the same dimensions
The one below is just an example of how to use logical indexing for your problem. data = ones(1,100); data(randi(100,1,10)) = ...

nästan 2 år ago | 0

Answered
Help with coding a model
I think this could be the solution to your problem % Parameters L = 80; gamma = 1e-2; R_0 = 0.7; beta = R_0*...

nästan 2 år ago | 1

| accepted

Answered
How do I use a variable assigned in one function to call another function?
The code does not global variables at all a = 5; b = 10; x = name1(a,b) y = name2(x,b) function out = name1(var1,var2) ...

nästan 2 år ago | 0

Answered
Plot polynomial using Eueler's method
so, initially, you calculate the analytical derivative of the function using the symbolic environment syms x y = x^3+x^2-12*...

nästan 2 år ago | 1

| accepted

Answered
Fill area inside a single curve with color without an outline?
You should remove unnecessary spaces (' EdgeColor' --> 'EdgeColor'). A = [3.538283063 300.2169197 3.712296984 321.9088937 ...

nästan 2 år ago | 0

| accepted

Answered
Create an array from file names to find if any files are missing
Take this example, where there should be a total of 4 files but file #3 is missing n = 4; % nu...

nästan 2 år ago | 0

Answered
Need to fill out skipped rows in a matrix
Take this example complete = [(1:10)',rand(10,1)] partial = [sort(randperm(10,6))',rand(6,1)] You can apply the following to ...

nästan 2 år ago | 0

| accepted

Answered
ismember for cell arrays of different sizes
bin_list = {[1], [1,7], [1,7], [1,7,9], [2,8], [3], [1,7]}' cellfun(@(x)ismember(1,x),bin_list)

nästan 2 år ago | 0

| accepted

Answered
Plot elipses with a foci based on equations to plot flowers
The code below does the job drawing the figure, but not the coloring. I can't run it online (takes too long). clear,clc figur...

nästan 2 år ago | 1

| accepted

Answered
How can i plot dy/dx function?
You can use deval in combination with solution structure. xspan = (30:0.1:900); y0 = 0; opts = odeset('AbsTol',1e-8,'RelTol',...

nästan 2 år ago | 0

| accepted

Answered
What is wrong with the function code when it can work perfectly without function code
The value of for tol differs of two orders of magnitude in the examples you gave (i.e., you used 0.001 in the function call, 0.0...

nästan 2 år ago | 0

Answered
Im trying to use the integral function without any success...
syms t f = exp(-t/3)* sin(t^2); I = int(f,t,1,4) This means int cannot compute the value of the definite integral. You could ...

nästan 2 år ago | 0

Answered
I'm getting an error (Index in position 1 exceeds array bounds)
Do this instead ind_out = signal(1,:) > max_thresh; %find index of point>thresh onset = signal(ind_out,1); %return onset ...

nästan 2 år ago | 0

Answered
Count occurances on multidimensional matrix with multiple criteia on different dimnesions
A(:,:,1) = [ 90 95 90 80;... 70 90 95 70;... 60 90 90 60;... ]; A(:,:,2) ...

nästan 2 år ago | 0

Solved


Magic is simple (for beginners)
Determine for a magic square of order n, the magic sum m. For example m=15 for a magic square of order 3.

nästan 2 år ago

Solved


Make a random, non-repeating vector.
This is a basic MATLAB operation. It is for instructional purposes. --- If you want to get a random permutation of integer...

nästan 2 år ago

Solved


Number of 1s in a binary string
Find the number of 1s in the given binary string. Example. If the input string is '1100101', the output is 4. If the input stri...

nästan 2 år ago

Solved


Create times-tables
At one time or another, we all had to memorize boring times tables. 5 times 5 is 25. 5 times 6 is 30. 12 times 12 is way more th...

nästan 2 år ago

Solved


Return the first and last characters of a character array
Return the first and last character of a string, concatenated together. If there is only one character in the string, the functi...

nästan 2 år ago

Answered
Can someone explain to me how to code the Tangent line and Normal line
syms x m b yt f(x) = 3^x+3*x+2; % Function m = diff(f,x) % Slope of tangent ...

nästan 2 år ago | 0

Answered
Finding specific values from a matrix
See the example below (I used a smaller array for better readibility) Values = randi(200,1,20) lower_limit=30; upper_limit=10...

nästan 2 år ago | 0

| accepted

Answered
Using fsolve in simulink with a different equation each time
In Simulink, you can keep a as a generic parameter syms x a eqn = (450 + 75 * cos(x) - 450 * cos(a))^2 + (110 + 450 * sin(a) -...

nästan 2 år ago | 0

| accepted

Answered
find and store the index value of maximum or minimum value of cell array
Example for row = 1:613 yourcellarray(row,1) = {randi(100,200,1)}; end yourcellarray yourcellarray{1} Above is just an...

nästan 2 år ago | 0

Answered
Help with Graphing Difference Equations
n = 10; x = zeros(1,10); x(1) = 2; x(2) = 5; for idx = 3:n x(idx) = 5*x(idx-1)-6*x(idx-2); end semilogy(1:n,x)

nästan 2 år ago | 0

| accepted

Answered
Running for loop on an equation
I suspect you want to do something like this S = [ 1/2, 1/3, 1/2, 1/3, 1/3, 1/2;... 1/2, 0, 0, 0, 0, 0;... ...

nästan 2 år ago | 1

Answered
perimeter , area of circle
You just need to change the arguments in fprintf, since you must have accidentally swapped them. r = 1; P = pi * 2 * r; S = p...

nästan 2 år ago | 0

| accepted

Answered
How to apply stop time condition with multiple time intervals?
n=100; time = 0; for i = 1:n if sum(time) >= 35 fprintf('You run out of time') break end ...

nästan 2 år ago | 1

| accepted

Answered
How do I find a maximum within a certain range
Take this example dataset x = linspace(0,10,100); y = randi(10,1,100).*sin(x); plot(x,y) Now assume you want to find the max...

nästan 2 år ago | 0

Answered
Method of lines to solve unsteady state PFR with multiple reactions
I deleted many commented lines for clarity. clear, clc k0 = [0.1023 0.0011 0.0129 0.0000001 0.0008 0.000001 0.163 0.5 0.01 0...

nästan 2 år ago | 1

Answered
Help with time dependent ODE with a piece-wise component
I think that the problem is that you already defined the ODE system as an anonymous function, therefore there's no need to call ...

nästan 2 år ago | 0

| accepted

Load more