Answered

How to find files with a given pattern in multiple folders

Try contains: function filefinder(file, directory) % List of the predefined directories to look into if nargin == 1 di...

How to find files with a given pattern in multiple folders

Try contains: function filefinder(file, directory) % List of the predefined directories to look into if nargin == 1 di...

más de 2 años ago | 1

Answered

How to plot a graphic with different markers in a scatter plot?

Is this what you mean? This is assuming that a,b,c,d,e,f are 3 element vectors. clear; load -ascii test1.txt; a=test1(:,1...

How to plot a graphic with different markers in a scatter plot?

Is this what you mean? This is assuming that a,b,c,d,e,f are 3 element vectors. clear; load -ascii test1.txt; a=test1(:,1...

más de 2 años ago | 0

| accepted

Answered

How to flip an axis on a plot without affecting the plot?

Try: axis(gca,'ij')

How to flip an axis on a plot without affecting the plot?

Try: axis(gca,'ij')

más de 2 años ago | 0

| accepted

Answered

Average of multiple matrices to create a new matrix with the same dimension.

If I am understanding your question right, you are wanting to find average of each element and ignore the nans? diret = 'New Fo...

Average of multiple matrices to create a new matrix with the same dimension.

If I am understanding your question right, you are wanting to find average of each element and ignore the nans? diret = 'New Fo...

más de 2 años ago | 1

| accepted

Answered

If statement "if column 1 == column 2 then keep row"

Have you tried something like this? subData = data(colA == colB);

If statement "if column 1 == column 2 then keep row"

Have you tried something like this? subData = data(colA == colB);

más de 2 años ago | 0

Answered

Puting empty value in numeric array

How about putting a NaN in it? Data(n,1)= NaN;

Puting empty value in numeric array

How about putting a NaN in it? Data(n,1)= NaN;

más de 2 años ago | 2

| accepted

Answered

How to store vectors from each for loop in a matrix

if true X= 1:0.1:2; A = 4; B = 1:5; Y = nan(length(X),length(B)); for i = 1:length(X) Y(i,:) =...

How to store vectors from each for loop in a matrix

if true X= 1:0.1:2; A = 4; B = 1:5; Y = nan(length(X),length(B)); for i = 1:length(X) Y(i,:) =...

más de 2 años ago | 1

| accepted

Answered

Array indices must be positive integers or logical values.

I ran your code and it works for me. This leads me to believe you might have a variable in your workspace named min. Try this: ...

Array indices must be positive integers or logical values.

I ran your code and it works for me. This leads me to believe you might have a variable in your workspace named min. Try this: ...

más de 2 años ago | 0

| accepted

Answered

List comprehension-like function in assigning values in nested structures

Try this: h = [data.h];

List comprehension-like function in assigning values in nested structures

Try this: h = [data.h];

más de 2 años ago | 1

| accepted

Answered

Why is this not outputting anything?

For this to work you need to set your intial MIN_VALUE to inf rather than 0. If its set to zero, it will only make output if you...

Why is this not outputting anything?

For this to work you need to set your intial MIN_VALUE to inf rather than 0. If its set to zero, it will only make output if you...

más de 2 años ago | 0

| accepted

Answered

Error storing structure within parfor

You could try storing it in a cell array and converting to structure after the parfor: names = cell(num_sim,1); results = cell...

Error storing structure within parfor

You could try storing it in a cell array and converting to structure after the parfor: names = cell(num_sim,1); results = cell...

más de 2 años ago | 0

| accepted

Answered

Why is this matrix instantly forming in the middle of the for loop?

When you calculate S_2, M_0 is subtracted in last part of the equation making it a 1x30 matrix. Should you be subtracting M_0(i)...

Why is this matrix instantly forming in the middle of the for loop?

When you calculate S_2, M_0 is subtracted in last part of the equation making it a 1x30 matrix. Should you be subtracting M_0(i)...

más de 2 años ago | 0

| accepted

Answered

Make 1 figure with 2 plots in 1 row. First plot will be empty, and second plot will contain bar plot of all values of i from one of the above loops.

subplot(1,2,1); subplot(1,2,2); bar(i)

Make 1 figure with 2 plots in 1 row. First plot will be empty, and second plot will contain bar plot of all values of i from one of the above loops.

subplot(1,2,1); subplot(1,2,2); bar(i)

más de 2 años ago | 0

Answered

How to use cell as input arguments of a function?

This works for me. Maybe matlab has another merge function? Type this: which merge Make sure the path its giving you points at...

How to use cell as input arguments of a function?

This works for me. Maybe matlab has another merge function? Type this: which merge Make sure the path its giving you points at...

más de 2 años ago | 1

| accepted

Answered

comparison of vectors and reducing size

If you want to just keep the first 299 elements: sz = min([length(A),length(B),length(C)]); A = A(1:sz); B = B(1:sz); C = C(...

comparison of vectors and reducing size

If you want to just keep the first 299 elements: sz = min([length(A),length(B),length(C)]); A = A(1:sz); B = B(1:sz); C = C(...

más de 2 años ago | 1

| accepted

Answered

Please provide insight and assistance with this issue I am having. I am new to Matlab, so any advice would be greatly appreciated.

You do not need the while loop, you can just use the for loop starting at 1 to string length in increments of 5. You also want t...

Please provide insight and assistance with this issue I am having. I am new to Matlab, so any advice would be greatly appreciated.

You do not need the while loop, you can just use the for loop starting at 1 to string length in increments of 5. You also want t...

más de 2 años ago | 0

Answered

Reading different lines with different numbers of data

This code is assuming that the only lines that have 3 fields is your data: file = 'filename.txt'; fileID = fopen(file); data ...

Reading different lines with different numbers of data

This code is assuming that the only lines that have 3 fields is your data: file = 'filename.txt'; fileID = fopen(file); data ...

más de 2 años ago | 2

| accepted

Answered

Combine three or more MATLAB figures

I would save figures then plot them as subplots like this: %First Figure h1 = openfig('test1.fig','reuse'); % open figure ax1...

Combine three or more MATLAB figures

I would save figures then plot them as subplots like this: %First Figure h1 = openfig('test1.fig','reuse'); % open figure ax1...

más de 2 años ago | 1

| accepted

Answered

No. of elements, mean and standard deviation of a field - conditions on other fields

Maybe something like this? f1 = [S.f1]; f2 = [S.f2]; f3 = [S.f3]; f1_cond1 = numel(f1(f1 > 50 & f1(f1 <=100))); f2_idx = ...

No. of elements, mean and standard deviation of a field - conditions on other fields

Maybe something like this? f1 = [S.f1]; f2 = [S.f2]; f3 = [S.f3]; f1_cond1 = numel(f1(f1 > 50 & f1(f1 <=100))); f2_idx = ...

más de 2 años ago | 0

| accepted

Answered

Rearrange an array based on a matrix

Would something like this work: for i = 1:numel(V) [~,k] = find(M == V(i)); col_v = M(:,k); col_v = col_v(col_v ...

Rearrange an array based on a matrix

Would something like this work: for i = 1:numel(V) [~,k] = find(M == V(i)); col_v = M(:,k); col_v = col_v(col_v ...

más de 2 años ago | 0

| accepted

Answered

How save an Array in nc

You need to save your lat, lon, time, and data to nc file. Look at documentaion for nccreate. It should be something like this b...

How save an Array in nc

You need to save your lat, lon, time, and data to nc file. Look at documentaion for nccreate. It should be something like this b...

más de 2 años ago | 0

Answered

Undefined Function or Variable

You are not setting R becuase you have it in a try catch block and it is throwing an error. That is because you are tryind to in...

Undefined Function or Variable

You are not setting R becuase you have it in a try catch block and it is throwing an error. That is because you are tryind to in...

más de 2 años ago | 1

Answered

Using ismember on vector with strings

if you are trying to match string to string, try this: if any(contains([' nafor','kform','acet'],result))

Using ismember on vector with strings

if you are trying to match string to string, try this: if any(contains([' nafor','kform','acet'],result))

más de 2 años ago | 0

| accepted

Answered

Parfor problems about loopVar = initVal:endVal

You are setting the variable xhat in the parfor and using the prevous itereation of xhat. You need to just access and set a slic...

Parfor problems about loopVar = initVal:endVal

You are setting the variable xhat in the parfor and using the prevous itereation of xhat. You need to just access and set a slic...

más de 2 años ago | 0

Answered

How to organize data in matrix

Did you preallocate output array? output_array = nan(60,45,348); for time_idx = 1:348 output_array(:,:,time_idx) = ncread...

How to organize data in matrix

Did you preallocate output array? output_array = nan(60,45,348); for time_idx = 1:348 output_array(:,:,time_idx) = ncread...

más de 2 años ago | 0

Answered

How to download multiple data files at once using matlab

Try this. I also put where you could change year also. year = 2019; start_jd = 182; end_jd = 212; for jd = start_jd:end_jd...

How to download multiple data files at once using matlab

Try this. I also put where you could change year also. year = 2019; start_jd = 182; end_jd = 212; for jd = start_jd:end_jd...

más de 2 años ago | 2

| accepted

Answered

reading of xls file without nan

Use this to get a cell array of mixed data types (doubles and char): [~,~,raw] = xlsread('myFile.xlsx')

reading of xls file without nan

Use this to get a cell array of mixed data types (doubles and char): [~,~,raw] = xlsread('myFile.xlsx')

más de 2 años ago | 0

| accepted

Answered

Picking one line from a .txt file.

Try this: filename = 'file.txt' linenum = 5; fileID = fopen(filename); C = textscan(fileID,'%s',1,'delimiter','\n', 'headerl...

Picking one line from a .txt file.

Try this: filename = 'file.txt' linenum = 5; fileID = fopen(filename); C = textscan(fileID,'%s',1,'delimiter','\n', 'headerl...

más de 2 años ago | 0

| accepted

Answered

Vectorization of a function

I think you have some of your dot operators wrong: d1 = (log(S./K) +(r+(1/2)*sigma^2)*t)/(sigma*sqrt(t)); d2 = d1-sigma*sqrt(t...

Vectorization of a function

I think you have some of your dot operators wrong: d1 = (log(S./K) +(r+(1/2)*sigma^2)*t)/(sigma*sqrt(t)); d2 = d1-sigma*sqrt(t...

más de 2 años ago | 1

Answered

Index in position 2 exceeds array bounds (must not exceed 1)

The variables u_c and u_p are vectors or the size of the second dimension is 1. Then you try to set these variables with i in th...

Index in position 2 exceeds array bounds (must not exceed 1)

The variables u_c and u_p are vectors or the size of the second dimension is 1. Then you try to set these variables with i in th...

más de 2 años ago | 1