Answered

Loop plotting for individual years

There's no legend in the example below, because I am not sure what you wanted to do with the cellfun function. Nevertheless, it...

Loop plotting for individual years

There's no legend in the example below, because I am not sure what you wanted to do with the cellfun function. Nevertheless, it...

5 months ago | 0

| accepted

Answered

How to vertically concatenate many tables produced from a for loop

I would try something like this M = []; for k=1:numel(A) % automatically brings in the correct amount of tables M = [M;re...

How to vertically concatenate many tables produced from a for loop

I would try something like this M = []; for k=1:numel(A) % automatically brings in the correct amount of tables M = [M;re...

5 months ago | 0

| accepted

Answered

plotting graph with 2 different size of vector

Applying diff to a Nx1 array produces an (N-1)x1 array, hence your problem. In truth, you are not really calculating the deriva...

plotting graph with 2 different size of vector

Applying diff to a Nx1 array produces an (N-1)x1 array, hence your problem. In truth, you are not really calculating the deriva...

5 months ago | 0

| accepted

Answered

Build a matrix with a gradual value of intensity and an horizontal line with a constant value

A = repmat(linspace(0,1,1000),500,1); A(220:280,:) = 0.5; imshow(A)

Build a matrix with a gradual value of intensity and an horizontal line with a constant value

A = repmat(linspace(0,1,1000),500,1); A(220:280,:) = 0.5; imshow(A)

5 months ago | 0

| accepted

Answered

removing specified data from variable

I think the following code is a simpler way of achieving your task, but it does not implement the "pulling a number from a rando...

removing specified data from variable

I think the following code is a simpler way of achieving your task, but it does not implement the "pulling a number from a rando...

5 months ago | 0

Answered

Call different functions inside a function

The way you have explained it in your question is already correct. See the example below. %% Main script mainfunction %% Mai...

Call different functions inside a function

The way you have explained it in your question is already correct. See the example below. %% Main script mainfunction %% Mai...

5 months ago | 1

Answered

Create an airfoil in MATLAB

From the wikipedia page https://en.wikipedia.org/wiki/NACA_airfoil t = 0.25; % maximum thickness as a fraction of the ch...

Create an airfoil in MATLAB

From the wikipedia page https://en.wikipedia.org/wiki/NACA_airfoil t = 0.25; % maximum thickness as a fraction of the ch...

5 months ago | 0

Answered

Saving Multiple .dat files

This should work A = rand(2000,1000); for col = 1:size(A,2) filename = ['Column_',num2str(col),'.dat']; writematri...

Saving Multiple .dat files

This should work A = rand(2000,1000); for col = 1:size(A,2) filename = ['Column_',num2str(col),'.dat']; writematri...

5 months ago | 0

| accepted

Answered

MATLAB double addition format long

I suggest reading the following thread https://ch.mathworks.com/matlabcentral/answers/1838113-wrong-sum-50-0-01

MATLAB double addition format long

I suggest reading the following thread https://ch.mathworks.com/matlabcentral/answers/1838113-wrong-sum-50-0-01

5 months ago | 0

| accepted

Answered

How do I find slope for large dataset?

Just do A = diff(data)./diff(time);

How do I find slope for large dataset?

Just do A = diff(data)./diff(time);

5 months ago | 0

| accepted

Answered

How do i set up a legend for a graph with variable parameters?

t = -2:0.1:4; d = 1; c = 1; A = 1:0.2:2; figure hold on for i = 1:length(A) y= A(i) * (t - d).*(t-c) ; plot (...

How do i set up a legend for a graph with variable parameters?

t = -2:0.1:4; d = 1; c = 1; A = 1:0.2:2; figure hold on for i = 1:length(A) y= A(i) * (t - d).*(t-c) ; plot (...

5 months ago | 0

Answered

Generate Alternating Tones Based On Number Of Cycles

I am still quite unsure if this is what you are asking, but I will give it a go. [t,w] = wave(465); plot(t,w) function [t,f] ...

Generate Alternating Tones Based On Number Of Cycles

I am still quite unsure if this is what you are asking, but I will give it a go. [t,w] = wave(465); plot(t,w) function [t,f] ...

5 months ago | 0

Answered

Interpolate data to present with limited size of data

x=rand(5,7) figure contourf(x,'LineColor','none') shading interp axis equal off

Interpolate data to present with limited size of data

x=rand(5,7) figure contourf(x,'LineColor','none') shading interp axis equal off

5 months ago | 1

| accepted

Answered

Getting A blank Graph

See below for a correct use of indexing with a for loop x = 0:0.01:1; for i = 1:length(x) y1(i) = (0.5*x(i)^5)-(0.6*x(i)^4)...

Getting A blank Graph

See below for a correct use of indexing with a for loop x = 0:0.01:1; for i = 1:length(x) y1(i) = (0.5*x(i)^5)-(0.6*x(i)^4)...

5 months ago | 0

Answered

trying to plot 3 variables in 3d

surf can handle only matrices, so this is what you want to do theta= linspace(.01, .55); %for thetamax = 32 degrees M=linspace...

trying to plot 3 variables in 3d

surf can handle only matrices, so this is what you want to do theta= linspace(.01, .55); %for thetamax = 32 degrees M=linspace...

5 months ago | 0

| accepted

Answered

While loop with all elements meeting the conditions

t = -100:200; F = t; indices = 1:100; while all(F(indices)<0) indices = indices + 1; end

While loop with all elements meeting the conditions

t = -100:200; F = t; indices = 1:100; while all(F(indices)<0) indices = indices + 1; end

5 months ago | 1

| accepted

Answered

Wrong sum 50 + 0.01

I don't think this is an issue at all, but it rather has to do with the max accuracy MatLab uses to store numbers. Such accurac...

Wrong sum 50 + 0.01

I don't think this is an issue at all, but it rather has to do with the max accuracy MatLab uses to store numbers. Such accurac...

5 months ago | 0

| accepted

Answered

solve multiple equation in one variable

I think the problem is that you have 5 equations and 4 variables, because p1 does not appear anywhere in the system. Therefore ...

solve multiple equation in one variable

I think the problem is that you have 5 equations and 4 variables, because p1 does not appear anywhere in the system. Therefore ...

5 months ago | 0

| accepted

Answered

How can i get a logical vector for all rows when compare each row of a column matrix with a another row column matrix

You can simply do A = randi(10,5) B = randi(10,5) l = A == B

How can i get a logical vector for all rows when compare each row of a column matrix with a another row column matrix

You can simply do A = randi(10,5) B = randi(10,5) l = A == B

5 months ago | 0

| accepted

Answered

How to delete previous values within a certain difference?

You can do this A = [1,2,3,4,20,21,22,35,36,37,38,50,51,52,53,54,57,70]; A = A(diff(A)>10)

How to delete previous values within a certain difference?

You can do this A = [1,2,3,4,20,21,22,35,36,37,38,50,51,52,53,54,57,70]; A = A(diff(A)>10)

5 months ago | 0

| accepted

Answered

How do I set some variables of a function to a constant and plot the others?

This is a possibility E = -3:.001:3; plot(E,Theta(E,1)) function out = Theta(E,Delta) out = zeros(size(E)); out(abs(E)<=D...

How do I set some variables of a function to a constant and plot the others?

This is a possibility E = -3:.001:3; plot(E,Theta(E,1)) function out = Theta(E,Delta) out = zeros(size(E)); out(abs(E)<=D...

5 months ago | 1

| accepted

Answered

How to delete adjacent values

A = [1 5 6 7 8 9 10 11 12 20 21 22 23]; A([false,diff(A) == 1]) = []

How to delete adjacent values

A = [1 5 6 7 8 9 10 11 12 20 21 22 23]; A([false,diff(A) == 1]) = []

5 months ago | 0

| accepted

Answered

IF statement not generating results?

data=load('artificial_slope_2.txt') %loading data % defining input values based of input txt file nx = data(:,4); ny = data(...

IF statement not generating results?

data=load('artificial_slope_2.txt') %loading data % defining input values based of input txt file nx = data(:,4); ny = data(...

5 months ago | 0

Answered

a problem in rectangular function.

You are using plot incorrectly, see below. a=1; syms t f=piecewise(a / 0.2e1 < abs(t), 0, abs(t) == a / 0.2e1, 0.1e1 / 0.2e1,...

a problem in rectangular function.

You are using plot incorrectly, see below. a=1; syms t f=piecewise(a / 0.2e1 < abs(t), 0, abs(t) == a / 0.2e1, 0.1e1 / 0.2e1,...

5 months ago | 1

| accepted

Answered

forward, backward, central finite differences with step sizes.

I took the liberty to give you an example with a different function, because the one in your question has a constant slope and d...

forward, backward, central finite differences with step sizes.

I took the liberty to give you an example with a different function, because the one in your question has a constant slope and d...

5 months ago | 0

Answered

Why does the code return an additional answer value that I have not asked for?

That is because you call the function without assigning it to a variable. Therefore Matlab assigns it to a variable called ans,...

Why does the code return an additional answer value that I have not asked for?

That is because you call the function without assigning it to a variable. Therefore Matlab assigns it to a variable called ans,...

5 months ago | 0

Answered

I'm not getting the correct result for the u, i want it in degree but the ans is not right, the plot is not smooth.

You did not give enough information to know what the end result should be, but if your interest is only to plot in degrees, then...

I'm not getting the correct result for the u, i want it in degree but the ans is not right, the plot is not smooth.

You did not give enough information to know what the end result should be, but if your interest is only to plot in degrees, then...

5 months ago | 0

Answered

How to pass a function handle as an argument in ode45?

Just use a semicolon, ode45 requires the output to be a column array. R = 0.5; l = 1; g = 9.81; omega = 0.25; F = @(t,y...

How to pass a function handle as an argument in ode45?

Just use a semicolon, ode45 requires the output to be a column array. R = 0.5; l = 1; g = 9.81; omega = 0.25; F = @(t,y...

5 months ago | 0

| accepted

Answered

How can I keep the yaxis label inside rather than outside

Other possibility, a bit cumbersome I'd say plot(1:10,1:10) xlabel('xlabel') ylabel('ylabel') a = gca; a.YTickLabels = {''}...

How can I keep the yaxis label inside rather than outside

Other possibility, a bit cumbersome I'd say plot(1:10,1:10) xlabel('xlabel') ylabel('ylabel') a = gca; a.YTickLabels = {''}...

5 months ago | 0