Answered

Integration fo function A(c) from -inf to +inf

A = @(c) sqrt(m/(2*pi*k*T1))*exp(-m/(2*k*T1)*(c-c_bar1)^2) q = integral(A,-inf,inf)

Integration fo function A(c) from -inf to +inf

A = @(c) sqrt(m/(2*pi*k*T1))*exp(-m/(2*k*T1)*(c-c_bar1)^2) q = integral(A,-inf,inf)

ungefär en månad ago | 0

| accepted

Answered

how do I append to an array within a loop with float values?

Try with this: k = 0:0.1:20; solutions = zeros(size(k)); for ii = 1:numel(k) a = -k(ii); b = -k(ii); soln= ...

how do I append to an array within a loop with float values?

Try with this: k = 0:0.1:20; solutions = zeros(size(k)); for ii = 1:numel(k) a = -k(ii); b = -k(ii); soln= ...

ungefär en månad ago | 0

Answered

Is it another command using to compare between vector and cell?

Then, to obtain the elements of U that doesn't exist in S, you can do: U = [1,2,3]; S = {1,2}; w = U(~ismember(U,cell2mat(S))...

Is it another command using to compare between vector and cell?

Then, to obtain the elements of U that doesn't exist in S, you can do: U = [1,2,3]; S = {1,2}; w = U(~ismember(U,cell2mat(S))...

ungefär en månad ago | 0

| accepted

Answered

How do I store the changing values of a variable (generated in a for loop) into a single file without overwriting the previous one?

n = 100; areatriangle = zeros(1,n) for ii = 1 : n areatriangle(ii) = .5*((ii/2)*ii); end or: areatriangle = .5/2*(1:n)...

How do I store the changing values of a variable (generated in a for loop) into a single file without overwriting the previous one?

n = 100; areatriangle = zeros(1,n) for ii = 1 : n areatriangle(ii) = .5*((ii/2)*ii); end or: areatriangle = .5/2*(1:n)...

ungefär en månad ago | 0

| accepted

Answered

How to find the position of points in a coordinate system?

Using for loops: R = zeros(numel(X),numel(Z)); for i = X for j = Z R(i,j) = sqrt(i.^2+j.^2); end end

How to find the position of points in a coordinate system?

Using for loops: R = zeros(numel(X),numel(Z)); for i = X for j = Z R(i,j) = sqrt(i.^2+j.^2); end end

ungefär en månad ago | 2

| accepted

Answered

position of values in a matrix

A = [23 24 35 2 12 19 24 23 12 15 26 17] loc = find(ismember(A,[35 2],'rows')) loc = 2

position of values in a matrix

A = [23 24 35 2 12 19 24 23 12 15 26 17] loc = find(ismember(A,[35 2],'rows')) loc = 2

ungefär en månad ago | 1

Answered

How to put a value in a plot label?

depth = [5,10,15,20]; for k = 1:4 kd = 0.0143.*5*k; SOTE = (a + kd + kp).*X.^beta.*5*k; figure(1) if k < 3 ...

How to put a value in a plot label?

depth = [5,10,15,20]; for k = 1:4 kd = 0.0143.*5*k; SOTE = (a + kd + kp).*X.^beta.*5*k; figure(1) if k < 3 ...

ungefär en månad ago | 0

| accepted

Answered

Why is this code not reading the csv file?

The images are useless, but the error is clear, your variable tdata doesn't exist. I guess you need to change this line: tdata ...

Why is this code not reading the csv file?

The images are useless, but the error is clear, your variable tdata doesn't exist. I guess you need to change this line: tdata ...

ungefär en månad ago | 0

Answered

ODE45, simple events

function [check,stop,direction]=landing(t,y) check = y; stop = 1; direction=0; end

ODE45, simple events

function [check,stop,direction]=landing(t,y) check = y; stop = 1; direction=0; end

ungefär en månad ago | 1

Answered

How to gracefully generate an all-one cell array?

function Output=OnesInCell(varargin) %This function should be the same as ones() except that each of the ones is packed into an...

How to gracefully generate an all-one cell array?

function Output=OnesInCell(varargin) %This function should be the same as ones() except that each of the ones is packed into an...

ungefär en månad ago | 0

| accepted

Answered

How to cut dimensions of 3d arrays in a cell.

Being A your cell array: newA = arrayfun(@(i) A{i}(700:720,300:360,:),1:numel(A),'uni',0)

How to cut dimensions of 3d arrays in a cell.

Being A your cell array: newA = arrayfun(@(i) A{i}(700:720,300:360,:),1:numel(A),'uni',0)

ungefär en månad ago | 1

Answered

selection of rows in a matrix

A = [36 13 9 21 23 32 35 5 3 43] B = A([1,3,5],:)

selection of rows in a matrix

A = [36 13 9 21 23 32 35 5 3 43] B = A([1,3,5],:)

ungefär en månad ago | 0

| accepted

Answered

Cannot call files named with ' character in the text

filename = '8''_Data_Startup-1234567489'

Cannot call files named with ' character in the text

filename = '8''_Data_Startup-1234567489'

2 månader ago | 1

| accepted

Answered

Exporting data from matlab to a excel with a special pathway

xlswrite(filename,Y1,1) xlswrite(filename,Y2,2) xlswrite(filename,Y3,3)

Exporting data from matlab to a excel with a special pathway

xlswrite(filename,Y1,1) xlswrite(filename,Y2,2) xlswrite(filename,Y3,3)

3 månader ago | 0

Answered

How do I code a function that's supposed to be an infinite pattern?

Another possibility: res = sum(x.*circshift(y,-1) - y.*circshift(x,-1))

How do I code a function that's supposed to be an infinite pattern?

Another possibility: res = sum(x.*circshift(y,-1) - y.*circshift(x,-1))

3 månader ago | 0

Answered

Best way to calculate the determinants of a series of matrices?

delta = arrayfun(@(t) det(squeeze(G(t,:,:))),1:size(G,1));

Best way to calculate the determinants of a series of matrices?

delta = arrayfun(@(t) det(squeeze(G(t,:,:))),1:size(G,1));

3 månader ago | 0

Answered

what is the error in this program

There is no error in your code, the problem is that it doesn't do whatt you want. I guess you want something like this (without ...

what is the error in this program

There is no error in your code, the problem is that it doesn't do whatt you want. I guess you want something like this (without ...

3 månader ago | 0

Answered

Errror using imwrite, can't use "append" in 'WriteMode'

You are changing the file name for each frame, resulting in different tif images. To build a tif stack you just need to use ONE ...

Errror using imwrite, can't use "append" in 'WriteMode'

You are changing the file name for each frame, resulting in different tif images. To build a tif stack you just need to use ONE ...

3 månader ago | 1

| accepted

Answered

How to generate a random integer between two bounds?

randi([4,500])

How to generate a random integer between two bounds?

randi([4,500])

3 månader ago | 0

| accepted

Answered

i want to plot 4 plots using ginput

Adding hold on: clear all; close all; hold on for k=1:4 axis([0,10,0,10]); data = ginput(4); x = data(:,1); y = data(:,2...

i want to plot 4 plots using ginput

Adding hold on: clear all; close all; hold on for k=1:4 axis([0,10,0,10]); data = ginput(4); x = data(:,1); y = data(:,2...

3 månader ago | 0

| accepted

Answered

Summing up values of A matrix if it matches the same value in B

One option: [G,ID] = findgroups(B); C = [splitapply(@sum,A,G),ID] C = 15.0000 32.1111 3.0000 34.6731 1.0000...

Summing up values of A matrix if it matches the same value in B

One option: [G,ID] = findgroups(B); C = [splitapply(@sum,A,G),ID] C = 15.0000 32.1111 3.0000 34.6731 1.0000...

3 månader ago | 0

| accepted

Answered

Problem in plotting the string variable

Do you mean this? Rough_y=[4;5;8;3;12;14;9;11;17;17;11;14;19;25;15] Station=['a';'b';'c';'d';'e';'f';'g';'h';'i';'j';'k';'l';'...

Problem in plotting the string variable

Do you mean this? Rough_y=[4;5;8;3;12;14;9;11;17;17;11;14;19;25;15] Station=['a';'b';'c';'d';'e';'f';'g';'h';'i';'j';'k';'l';'...

3 månader ago | 0

Answered

How can i use Inverse for symbolic variables?

syms x y a b c d A = [ a*(x^2) , b*(y^3) ; d*(x^2)*y , c ]; inv(A) ans = [ c/(- b*d*x^2*y^4 + a*c*x^2), -(b*y^3)/(- b*d*x^...

How can i use Inverse for symbolic variables?

syms x y a b c d A = [ a*(x^2) , b*(y^3) ; d*(x^2)*y , c ]; inv(A) ans = [ c/(- b*d*x^2*y^4 + a*c*x^2), -(b*y^3)/(- b*d*x^...

4 månader ago | 1

| accepted

Answered

problem with reading data from excel

Do you mean this? data = xlsread('yourExcel.xlsx'); data = data(2:end,2:end) data(2,4) %For example: x1 = 2; x2 = 4

problem with reading data from excel

Do you mean this? data = xlsread('yourExcel.xlsx'); data = data(2:end,2:end) data(2,4) %For example: x1 = 2; x2 = 4

4 månader ago | 0

| accepted

Answered

Checking for existence of row in a matrix

Try with this: my_mat = [1 2 4 5 3 1 6 9 7]; new = [6 9]; Lia = ismember(my_mat(:,1:2),new,'rows'); ...

Checking for existence of row in a matrix

Try with this: my_mat = [1 2 4 5 3 1 6 9 7]; new = [6 9]; Lia = ismember(my_mat(:,1:2),new,'rows'); ...

4 månader ago | 0

| accepted

Answered

How to repeat loop until condition is met? While or For Loop?

Something like this would be a good solution: x = %Initialization A = x + 1.5; B = x^2 + 1; Error = A-B; iter = 1; while ...

How to repeat loop until condition is met? While or For Loop?

Something like this would be a good solution: x = %Initialization A = x + 1.5; B = x^2 + 1; Error = A-B; iter = 1; while ...

4 månader ago | 0

| accepted

Answered

Differentiating gives wrong result

I don't know why the result is presented in different way depending on the case, but the result is allways the same: %Case 1 s...

Differentiating gives wrong result

I don't know why the result is presented in different way depending on the case, but the result is allways the same: %Case 1 s...

4 månader ago | 0

| accepted

Answered

Array indices must be positive integers or logical values

You are trying to acces to: B(0), B(0.1) and so on, which are not allowed indexes. Try with this: %% MAGNETORQUER SIZING clear...

Array indices must be positive integers or logical values

You are trying to acces to: B(0), B(0.1) and so on, which are not allowed indexes. Try with this: %% MAGNETORQUER SIZING clear...

4 månader ago | 0

| accepted

Solved

Back and Forth Rows

Given a number n, create an n-by-n matrix in which the integers from 1 to n^2 wind back and forth along the rows as shown in the...

4 månader ago