Answered
I get this error 'index in position 1 is invalid. Array indices must be positive integers or logical values.' when I am trying to store values from a for loop into a vector.
n = 9; % set the number of Monte Carlo repetitions M = 10000; % create M*1 vectors to save the realized sample statisti...

5 years ago | 0

| accepted

Answered
How to resolve the error of "Consider preallocating for speed" which is coming on executing the program below??
The answer is here: <https://de.mathworks.com/help/matlab/matlab_prog/preallocating-arrays.html>

5 years ago | 0

Answered
Solving System of two Differential Equations with one initial and one end condition
Symbolic appears to work: syms Th(x) Tc(x) m_hp = 20; m_cp = 5; cw = 1; Rw = 1; eq(1) = diff(Th,x) == -1 / ((m_hp / 2) *...

5 years ago | 1

| accepted

Answered
2 values for inputs of a function
In case of a vectorized function (yours is) you can use vector inputs: b = 5; c = [25; 60]; d = 0; [T, L] = answ(b,c,d) ...

5 years ago | 0

Answered
How to vectorise this function
NumI = sum(Value < 10000); Elements = zeros(5000, NumI);

5 years ago | 0

Answered
Deleting specific rows in an excel file
Download the attached file - and copy it in your working directory: T = readtable('TriggerHintExample.xlsx') T(T.TriggerHint >...

5 years ago | 0

| accepted

Answered
How can I find the coefficients of this polynomial?
x = [0 1 3 4]; y = [10 35 31 2]; coeffs = polyfit(x,y,3) plot(0:0.1:5,polyval(coeffs,0:0.1:5),'b-') hold on scatter(x,y,'bo...

5 years ago | 0

Answered
Solving an equation with an unknown in the numerator and denominator
syms M k A = (k+1)/(2*(k-1)); D = k-1; E = k+1; eqn = (1/M)*((2+(D*M^2))/(E))^A == 3.5; sol = vpasolve(eqn); prett...

5 years ago | 0

Answered
First five natural frequency of cracked nanoarch
Try to keep working symbolic, by using solve: syms logw k; w=exp(logw); E=10^7; ro=0.1;h=0.01289;b=0.1016; I=b*h^3/12; Z=b*...

5 years ago | 0

Answered
Find the cell which is containing a string
A={'Dimension','Weight','Qty','Thk','Total Price'}; [r,c] = find(contains(A,'Price'))

5 years ago | 1

| accepted

Answered
solve two equations with 2 unknowns(pbar,rho)
Try numeric: format long S0 = [0.1, 0]; S = fsolve(@eqns,S0) TestSolution = eqns(S) % Should be near zero for a good soluti...

5 years ago | 0

Answered
Using fsolve in for loop for find solutions to equation
Add this line before you call fsolve options = optimoptions('fsolve','Display','off'); and then call fsolve with this o...

5 years ago | 1

| accepted

Answered
I'd like to draw 2D image with excel file data
% Enter filename + path here: filename = 'basic_matrix.xls' % Get data from excel into array M = readmatrix(filename); % plo...

5 years ago | 0

Answered
Suppressing Functions Without Removing Output
% This script calculates the area of a circle % It prompts the user for the radius radius = input('Please enter the radius: ')...

5 years ago | 0

| accepted

Answered
Cant get makima to work
makima was introduced in R2019b - with R2018b it can not work. If possible update your matlab release.

5 years ago | 0

| accepted

Answered
How to change output format from solve function
double(dist)

5 years ago | 1

| accepted

Answered
Help with coding (integral)
Typo in line 18 - use sum_f instead of sum_ f a = 0; b = 1; n = 20; m = n/2; dx = (b-a)/n; x = a; sum_f = ((1...

5 years ago | 0

| accepted

Answered
Counting coins on a greyscale image - using morphological and/or f transforms
I = imread('image.png'); I = imadjust(I); [centers,radii] = imfindcircles(I,[15 75],'ObjectPolarity','dark','Sensitivity',0.85...

5 years ago | 0

| accepted

Answered
How to solve to get temperature profile of T_go and T_pousing ode45 solver
% Write the system symbolic syms A B C D E F G T_go(t) T_po(t) eq(1) = A * diff(T_go,t) == (B*T_go)+(C*T_po)+(D*(T_po^4-T_go^4...

5 years ago | 0

| accepted

Answered
How can I connect avg points
You might want to use the yline function: DAN=[ 19.83 1000.7; 16.72 997.2; 18.47 1012.9; 21.06 987.3; 17.99 1005.1; 18.25 ...

5 years ago | 1

| accepted

Answered
finding root of a three variable function
You can try fsolve: % example function % x(1) = x % x(2) = y % x(3) = z fun = @(x) 3*cos(x(1)) - x(2).^1/3 + x(3) - 7 op...

5 years ago | 0

Answered
Error with size( )
size is an inbuilt function which uses at least on input argument. If you call the function without an input argument you end up...

5 years ago | 0

Answered
Reading Excel named table doesn't work ?
data = readtable('test.xlsx') results in: data = 11×2 table ID Data __ _____ 1 21324 ...

5 years ago | 0

Answered
plotting problem: getting empty graph window
fun = @(x) cos(8*pi.*x)./(1+x.^2) fplot(fun,[-1, 1])

5 years ago | 1

Answered
error Attempt to execute SCRIPT kmeans as a function:
Rename your script. kmeans is an inbuild function, which is shadowed by your script. In general script names should not be named...

5 years ago | 1

Answered
How to get random values from a matrix
% Test data to play with A = rand(12,1000); % Preallocate idx = zeros(size(A,1),5); % 5 unique random indices for every ...

5 years ago | 1

Answered
.append() equivalent in MATLAB
>> List = [1 2 3; 4 5 6] List = 1 2 3 4 5 6 >> List = [List; 7 8 9] List = 1 ...

5 years ago | 3

| accepted

Answered
Varying Variables within a Function
%Setting the time interval in seconds tspan = [0 20]; %% Define the values to iterate through m = [2, 3, 4, 5, 6]; %mass ...

5 years ago | 0

| accepted

Answered
Error in Ode23 line 114
[tsol,hsol] =ode23(@(t,h) TnkODE(t,h), [0 2000],[5 5]); plot(tsol,hsol) function Diff=TnkODE(~,h) h1=h(1); h2=h(2); % given ...

5 years ago | 1

| accepted

Answered
solving algebraic equations and characteristic vectors
Try: syms x sol = solve(x^2-5*x+6==0) Character is a data type that is defined by '...' like you did. For symbolic expr...

5 years ago | 0

| accepted

Load more