Answered

How to start streamlines on the surface of a sphere? griddedInterpolant requires at least two sample points in each dimension

It looks like streamline does not accepts coordinates coming from your spherical construction. If you start form a cartesian gri...

How to start streamlines on the surface of a sphere? griddedInterpolant requires at least two sample points in each dimension

It looks like streamline does not accepts coordinates coming from your spherical construction. If you start form a cartesian gri...

2 years ago | 2

| accepted

Answered

n! permutation matrices

Is this what you wish? % identity matrix A = eye(4); % permuatations idx = perms(1:4); % all matrices in a cell array B = ...

n! permutation matrices

Is this what you wish? % identity matrix A = eye(4); % permuatations idx = perms(1:4); % all matrices in a cell array B = ...

2 years ago | 0

Answered

Solve the system of the 1-st order differential equations

Have a look at the ode suite

Solve the system of the 1-st order differential equations

Have a look at the ode suite

2 years ago | 0

Answered

How to make two vectors the same size?

Try fkld=sum(dot(p,log(p./q))); with the element-wise division ./

How to make two vectors the same size?

Try fkld=sum(dot(p,log(p./q))); with the element-wise division ./

2 years ago | 1

| accepted

Answered

Inner matrix dimensions must agree

fkj= sum(.5*((p.^2-q.^2).^2)./((p.*q).^1.5)); Note that .^ .* and ./ operators are used for element-wise operation (see also St...

Inner matrix dimensions must agree

fkj= sum(.5*((p.^2-q.^2).^2)./((p.*q).^1.5)); Note that .^ .* and ./ operators are used for element-wise operation (see also St...

2 years ago | 1

| accepted

Answered

Inverse matrix in Matlab very different to Excel

The answer is not very different. As Jeremy commented, the results are similar a part from numerical tolerances. You can verify ...

Inverse matrix in Matlab very different to Excel

The answer is not very different. As Jeremy commented, the results are similar a part from numerical tolerances. You can verify ...

2 years ago | 1

| accepted

Answered

How to call a multi output function without repeating the run

function [c, ceq] = nonconst(x) [total_value, Delta_value, energy_value] = digital(x); c = total_value-u*v;... ` `%fi...

How to call a multi output function without repeating the run

function [c, ceq] = nonconst(x) [total_value, Delta_value, energy_value] = digital(x); c = total_value-u*v;... ` `%fi...

2 years ago | 0

| accepted

Answered

How to color a mesh by temperature(or other value) preserving the elevation. Using two matrix(same length)

% dummy data [X,Y] = meshgrid(1:0.5:10,1:20); Z = sin(X).*cos(Y); T = X+Y; % plot surf(X,Y,Z,T) colormap('hot') colorba...

How to color a mesh by temperature(or other value) preserving the elevation. Using two matrix(same length)

% dummy data [X,Y] = meshgrid(1:0.5:10,1:20); Z = sin(X).*cos(Y); T = X+Y; % plot surf(X,Y,Z,T) colormap('hot') colorba...

2 years ago | 1

| accepted

Answered

How can I get an array of velocity if I have an array of position and another array of time

First, you need a element-wise division pos = [0 2 4 8 16 32 64]; t = [0 0.1 0.2 0.3 0.4 0.5 0.6]; V = diff(pos)./diff(t); ...

How can I get an array of velocity if I have an array of position and another array of time

First, you need a element-wise division pos = [0 2 4 8 16 32 64]; t = [0 0.1 0.2 0.3 0.4 0.5 0.6]; V = diff(pos)./diff(t); ...

2 years ago | 0

| accepted

Answered

Numerical Solution for a System of THREE Differential Equations

This is an ODE, not PDE. Look for the ODE suite

Numerical Solution for a System of THREE Differential Equations

This is an ODE, not PDE. Look for the ODE suite

2 years ago | 0

| accepted

Answered

Area under curves with different length (trapz)

If you have the x axes for both waves, it is pretty easy to use trapz: N1 = 1036; N2 = 9958; % wave 1 x1 = linspace(0,2*pi...

Area under curves with different length (trapz)

If you have the x axes for both waves, it is pretty easy to use trapz: N1 = 1036; N2 = 9958; % wave 1 x1 = linspace(0,2*pi...

2 years ago | 1

| accepted

Answered

Plotting the integral of a graph

Suppose that x and y are the vectors defining your waveform. % dummy values x = linspace(0,2*pi,1000); y = sin(x); % integ...

Plotting the integral of a graph

Suppose that x and y are the vectors defining your waveform. % dummy values x = linspace(0,2*pi,1000); y = sin(x); % integ...

2 years ago | 1

| accepted

Answered

Does anybody know how to write a function which returns the coordinates of a convex hull of a list of certain points?

% your data N = 20; List = rand(N,2); % convex hull (k is the pointer to the rows in List with the convex hull k = convhul...

Does anybody know how to write a function which returns the coordinates of a convex hull of a list of certain points?

% your data N = 20; List = rand(N,2); % convex hull (k is the pointer to the rows in List with the convex hull k = convhul...

2 years ago | 0

Answered

How to divide a part of array to the another part of it?

T = psi2(1:5)./psi(end-4:end);

How to divide a part of array to the another part of it?

T = psi2(1:5)./psi(end-4:end);

2 years ago | 0

| accepted

Answered

How can speed up the blow codes?

Edit: added attempt for ncount I don't understand what ncount is doing, it looks like a counter but I don't understand why you ...

How can speed up the blow codes?

Edit: added attempt for ncount I don't understand what ncount is doing, it looks like a counter but I don't understand why you ...

2 years ago | 0

Answered

Array indices must be positive integers or logical values

Your index k starts from 0 and you are indexing h with k, so you are asking at the first iteration h(0). Matlab has 1-indexing s...

Array indices must be positive integers or logical values

Your index k starts from 0 and you are indexing h with k, so you are asking at the first iteration h(0). Matlab has 1-indexing s...

2 years ago | 0

Answered

while loop performance improvement

I don't know the starting value of k, assuming it is 1 idx = 1:rate:period mysum = sum(array(idx,2)); % note that sum is the n...

while loop performance improvement

I don't know the starting value of k, assuming it is 1 idx = 1:rate:period mysum = sum(array(idx,2)); % note that sum is the n...

2 years ago | 1

| accepted

Answered

Euler method error in code Index exceeds the number of array elements (1). in my my code

Checking the sintax of the code only I see 3 issues 1) In the for loop you wrote a(400-x(n)), that is you are addressing the po...

Euler method error in code Index exceeds the number of array elements (1). in my my code

Checking the sintax of the code only I see 3 issues 1) In the for loop you wrote a(400-x(n)), that is you are addressing the po...

2 years ago | 1

| accepted

Answered

Population growth in 7 years

% rate r = 0.0063; % years t = 7; % initial population a = 5e6; % population y = a*(1+r)^t

Population growth in 7 years

% rate r = 0.0063; % years t = 7; % initial population a = 5e6; % population y = a*(1+r)^t

2 years ago | 2

| accepted

Answered

Apply operation to each element of an array

You should use element-wise operations https://it.mathworks.com/help/matlab/matlab_prog/array-vs-matrix-operations.html In you...

Apply operation to each element of an array

You should use element-wise operations https://it.mathworks.com/help/matlab/matlab_prog/array-vs-matrix-operations.html In you...

2 years ago | 0

| accepted

Answered

How do you solve for a double sum

There are some things that are vgue, like the x-axis, in any case, this code shows something similar to the desired result clea...

How do you solve for a double sum

There are some things that are vgue, like the x-axis, in any case, this code shows something similar to the desired result clea...

2 years ago | 2

| accepted

Answered

Solving System of Equations

It seems you are solving a numeric system of equations. Why don't you simply put the coefficient matrix in A and the right-hand-...

Solving System of Equations

It seems you are solving a numeric system of equations. Why don't you simply put the coefficient matrix in A and the right-hand-...

2 years ago | 0

Answered

Finding values within a matrix

It is difficult to answer because we don't have the data files 'areatemp1' and 'machtemp1'. In any case in your if statement yo...

Finding values within a matrix

It is difficult to answer because we don't have the data files 'areatemp1' and 'machtemp1'. In any case in your if statement yo...

2 years ago | 0

Answered

Making a 3D Matrix and Adding Matrices to make a bigger matrix

In the loop, you wrote T(i+k-1,j+k-1) = d(i,j,k-1); k starts from one, so you are trying to access the d(i,j,0) elemen...

Making a 3D Matrix and Adding Matrices to make a bigger matrix

In the loop, you wrote T(i+k-1,j+k-1) = d(i,j,k-1); k starts from one, so you are trying to access the d(i,j,0) elemen...

2 years ago | 0

Answered

Computational Electromagnetics and MATLAB

This could be a good start https://it.mathworks.com/academia/books/computational-electromagnetics-with-matlab-sadiku.html

Computational Electromagnetics and MATLAB

This could be a good start https://it.mathworks.com/academia/books/computational-electromagnetics-with-matlab-sadiku.html

2 years ago | 1

| accepted

Answered

Why am i getting the : errir using inv ,Matrix must be square?

As James Tursa said, inv(H) is not defined when H is not square. If you have the matrix H and the rhs g, simply use f = H\g;

Why am i getting the : errir using inv ,Matrix must be square?

As James Tursa said, inv(H) is not defined when H is not square. If you have the matrix H and the rhs g, simply use f = H\g;

2 years ago | 0

Answered

Struggling to Vectorize the following Code.

Almost all execution time is due to the plot function as highlighted by the profiler: You can call the plot only once at the ...

Struggling to Vectorize the following Code.

Almost all execution time is due to the plot function as highlighted by the profiler: You can call the plot only once at the ...

2 years ago | 0

Answered

How can I pick certain element from each row of an array ?

I see that the edges shared by two triangles are not duplicated. To check for this case I sorted the nodes and the edges. Let me...

How can I pick certain element from each row of an array ?

I see that the edges shared by two triangles are not duplicated. To check for this case I sorted the nodes and the edges. Let me...

2 years ago | 0

| accepted

Answered

Combining my newton's method function for nonlinear equations and my lu decomposition function.

Is this what you are asking for? delta = LUgauss(J(x0),-F_value); Note that the buil-in lu Matlab function can do the work for...

Combining my newton's method function for nonlinear equations and my lu decomposition function.

Is this what you are asking for? delta = LUgauss(J(x0),-F_value); Note that the buil-in lu Matlab function can do the work for...

2 years ago | 0