已回答
How to solve for three answers from 3 equations using fsolve
Below, see an example of how to solve the system. I had to make up the values of the constants since you have not specified the...

2 years 前 | 0

| 已接受

已回答
Adding every loop a matrix from the right side to a matrix
In the example below, a new 2x2 random matrix is created at each new iteration and appended to an existing matrix A. clear,clc ...

2 years 前 | 0

已回答
assigning argument of function within function
The error is in the last line of the function fix. Change that and the code works. fix(rand(1,10)) % complete function funct...

2 years 前 | 0

已回答
conversion of yes no into logical array
clear,clc T = readtable('gridstability.csv') If you are ok with T.stabf being populated by true/false values, you can use. T....

2 years 前 | 0

| 已接受

已回答
I have to create a square wave signal on simulink where any logical value, high or low, must last for a given time. Logical values and times are sent by other simulink blocks.
Maybe something like this? clear,clc T = [3,6,2,1,4,3,8]; V = [1,0,1,0,1,0,1]; % Block t = cumsum(T); t = [0,repelem(t...

2 years 前 | 0

已回答
How do I find sin of a cell variable (el)?
If the value is stores in a cell, then you should write el{PRN,t} in order to extract the value as a double.

2 years 前 | 0

已回答
Sort a variables in structure
See example below clear,clc s.var_1 = 1; s.var_6 = 1; s.var_3 = 1; s.var_2 = 1; s.var_5 = 1; s.var_4 = 1; s order...

2 years 前 | 0

| 已接受

已回答
Runga-Kutta Method for system of first order differential equations
Two things: 1 - By defining two different functions for y1 and y2 you decouple the system, which is the source of the main prob...

2 years 前 | 0

| 已接受

已回答
Free Radical Polymerization for Copolymers AA and Styrene using pseudokinetic rate constants
You just need to calculate all the quantitites inside the ODE function as well. If you need those quantities to be plotted, the...

2 years 前 | 0

| 已接受

已回答
Fitting data to a known function using numerical solution
I suggest an extensive reading of the following documentation https://ch.mathworks.com/help/curvefit/fit.html https://ch.mathw...

2 years 前 | 0

| 已接受

已回答
2nd order diff equation for ode23/45?
The way you coded the ODE system is incorrect. See below clear,clc % Numerical solution tspan = [1 4]; y0 =...

2 years 前 | 1

| 已接受

已回答
Writing a loop to create a matrix
Example A = rand(3) n = 10; lambda = []; for i = 1:n lambda = [lambda;A.^i]; end lambda

2 years 前 | 1

| 已接受

已回答
Diagonal sums with non-zero elements
%define A A = [0 0.4 0.3 0.3; 0 0 0.5 0.5; 0.5 0.3 0 0.2; 0.5 0.3 0.2 0]; [n,n] = size(A); %find all permutations of A B =...

2 years 前 | 1

已回答
how to count the number of lines of an external txt file
Not sure if there is a better way, but this will work fid = fopen('a.txt','r'); n = 0; while ~feof(fid) fgetl(fid); ...

2 years 前 | 0

已回答
Plotting differential equations using ODEs with multiple initial conditions, trying to recreate a plot
I could not run the code, because several constants are missing (e.g. alpha1,beta1 etc.) The error in your code is that you hav...

2 years 前 | 0

已回答
Unrecognized function or variable 'qdpfun"
Below, I show the right way to pass extra parameters to a function. clear,clc dP = -18*1.01325e5; dz = 100; rho = 1e3; ...

2 years 前 | 1

| 已接受

已回答
Can someone help me understand why I cant get a graph with an alpha of 0.001
Following @Jan comprehensive answer, I think a code like the one suggested below might be a good solution to your problem clear...

2 years 前 | 1

已回答
find indexes of two values that between them there is specific number
clear,clc A = [1 5 3 10 38 27]; B = 2; % Interpolattion values idx = 1:2:2*length(A)-1; newA = interp1(idx,A,1:idx(end...

2 years 前 | 0

已回答
Runge-Kutta for multiple variables
Hi @Juliana Quintana, the problem is that by defining 4 different function handles and 4 different loops, you have decoupled the...

2 years 前 | 1

| 已接受

已回答
How to make vector of Unicode characters align with 1x2 matrix of numbers
clear,clc playerCards = []; storeUnicode = []; allSuites = [9824 9827 9829 9830]; % all possible uni...

2 years 前 | 0

| 已接受

已回答
Plot differential equations with respect to two variables in a 3d plane
You can use surf https://ch.mathworks.com/help/matlab/ref/surf.html or contourf https://ch.mathworks.com/help/matlab/ref/cont...

2 years 前 | 0

| 已接受

已回答
Append results of two 'for loops' into a single variable
You could store the accuracies of the first loop into a variable named a1 and those of the second loop into a variables named a2...

2 years 前 | 0

已回答
how to draw contour plot
The problem was in your use of linspace x = linspace(0,0.05,100); y = linspace(0,1,100); [xm,ym] = meshgrid(x,y); R0 = xm....

2 years 前 | 1

已回答
How can I make a integration with trapz?
I don't think you really need trapz for this function clear,clc x=[0,-0.0476,-0.0476,-0.0952,-0.0952,-0.1429,-0.1429,-0.1905...

2 years 前 | 0

已回答
How to run multiple randi fucntions with for loop without having indicing problems. (nearest neighbor interaction problem).
clear, clc for idx = 1:1000 M = randi([0, 1], 12, 12); M(M == 0) = -1; M(:,[1 end]) = 0; M([1 ...

2 years 前 | 0

| 已接受

已回答
How to vary an element in a matrix?
clear,clc k1 = 0.5*180:1.5*180; k2 = 50; k3 = 220; m1 = 1.1; m2 = 3.4; omega_nf = zeros(2,length(k1)); for idx = ...

2 years 前 | 0

已回答
superimpose a line of slope (-5/3) on a log-log graph
See example below clear,clc x = [1e1,1e4]; slope = -3/5; offset = 1; y = slope*x+offset; loglog(x,y,'--r')

2 years 前 | 0

已解决


The Hitchhiker's Guide to MATLAB
Output logical "true" if the input is the answer to life, the universe and everything. Otherwise, output logical "false".

2 years 前

已回答
Sum cumulative value from all files that is summoned in a loop
Inside the loop write row_length(i) = length(dataset.time); After the loop, you can calculate the summ of all lengths with su...

2 years 前 | 0

| 已接受

已回答
Make a point move to a destination coordinate
I am not sure what you mean when you say "there is no graph used", but maybe something like the exa,ple below might help. clear...

2 years 前 | 0

| 已接受

加载更多