Answered

Error changing data in table from char to double

This is to explain what is happening when using the function detectImportOptions: It seems the csv file format is inconsistent....

Error changing data in table from char to double

This is to explain what is happening when using the function detectImportOptions: It seems the csv file format is inconsistent....

1 year ago | 0

Answered

Specifying axis title for a specific tick mark range

From the figure window, click menu Insert --> TextBox

Specifying axis title for a specific tick mark range

From the figure window, click menu Insert --> TextBox

1 year ago | 0

Answered

Calculation with strcmp with variable values

[C,idx1,idx2] = innerjoin(Tab1,Tab2, "LeftKeys",{'Description','Year'},"RightKeys",{'Description','Year'}); [~,idx3] = join(C, ...

Calculation with strcmp with variable values

[C,idx1,idx2] = innerjoin(Tab1,Tab2, "LeftKeys",{'Description','Year'},"RightKeys",{'Description','Year'}); [~,idx3] = join(C, ...

1 year ago | 0

| accepted

Answered

values of equation in last iteration in fmincon

After the fmincon is run and you got the solution vector, make a call to the objective function using the solution vector but in...

values of equation in last iteration in fmincon

After the fmincon is run and you got the solution vector, make a call to the objective function using the solution vector but in...

1 year ago | 0

| accepted

Answered

Multiple boxplots on one figure

boxplot([W1;W2]','notch','on','Labels',{'recent windspeeds','last years windspeeds'})

Multiple boxplots on one figure

boxplot([W1;W2]','notch','on','Labels',{'recent windspeeds','last years windspeeds'})

1 year ago | 0

Answered

First input argument must be a function handle.

You cannot use nonscalar arrays of function handles .. use cell arrays instead: % your code dE{i} = @(t) 0.5*(-((X0(i)-Ts)./Ts...

First input argument must be a function handle.

You cannot use nonscalar arrays of function handles .. use cell arrays instead: % your code dE{i} = @(t) 0.5*(-((X0(i)-Ts)./Ts...

1 year ago | 0

| accepted

Answered

How i plot vector in workspace but i have only name the vector i want plot

plot(eval(vars{1})); % 'BB1UN' plot(eval(vars{2})); % 'BB1UR'

How i plot vector in workspace but i have only name the vector i want plot

plot(eval(vars{1})); % 'BB1UN' plot(eval(vars{2})); % 'BB1UR'

1 year ago | 1

Answered

Plot tabel in a loop

It seems that the first column of dat is a text label then you can define a cell array of the possible lables and create a doubl...

Plot tabel in a loop

It seems that the first column of dat is a text label then you can define a cell array of the possible lables and create a doubl...

1 year ago | 0

Answered

Populate a table (or concatenate a cell array) with various data types

Try this function which will prety much do the job for you. You may optimize it to preallocate A as well. function A = cell_for...

Populate a table (or concatenate a cell array) with various data types

Try this function which will prety much do the job for you. You may optimize it to preallocate A as well. function A = cell_for...

1 year ago | 0

| accepted

Answered

Create unique matrices from existing matrix using datenum

I am not sure what you are planning to do eventually. However, the following code does what you have explained. % smallest time...

Create unique matrices from existing matrix using datenum

I am not sure what you are planning to do eventually. However, the following code does what you have explained. % smallest time...

1 year ago | 1

| accepted

Answered

How can I change the way Matlab fills in my matrix?

B(:,:,i) = reshape(A(i,:),37,31)';

How can I change the way Matlab fills in my matrix?

B(:,:,i) = reshape(A(i,:),37,31)';

1 year ago | 0

| accepted

Answered

How to save in n different variables string data separated by comma

% RX='0.036,0.029' v = sscanf(RX, '%g,%g'); A = v(1); B = v(2);

How to save in n different variables string data separated by comma

% RX='0.036,0.029' v = sscanf(RX, '%g,%g'); A = v(1); B = v(2);

1 year ago | 0

| accepted

Answered

How to draw line and hold it?

Add this code after the line N=size(M); (you don't need N in this code anymore) % round to the nearest integer S1_x=round(S(1,...

How to draw line and hold it?

Add this code after the line N=size(M); (you don't need N in this code anymore) % round to the nearest integer S1_x=round(S(1,...

1 year ago | 0

| accepted

Answered

I have 28*6 cell as seen in the picture. Except for the first column, I need all the other columns to have equal lengths by filling them up with zeros in the end. Thanks in advance.

% ca is your cellarray ii = cellfun(@isnumeric, ca); m = max(cellfun(@numel, ca(ii))); ca(ii) = cellfun(@(x)[x;zeros(m-numel(...

I have 28*6 cell as seen in the picture. Except for the first column, I need all the other columns to have equal lengths by filling them up with zeros in the end. Thanks in advance.

% ca is your cellarray ii = cellfun(@isnumeric, ca); m = max(cellfun(@numel, ca(ii))); ca(ii) = cellfun(@(x)[x;zeros(m-numel(...

1 year ago | 0

| accepted

Answered

Cannot set quiver head size bigger than 1/3 of the length of the arrow.

There is a cutoff on how big the head size is compared to the norm of the arrow. If you can allow the norm to get longer you wil...

Cannot set quiver head size bigger than 1/3 of the length of the arrow.

There is a cutoff on how big the head size is compared to the norm of the arrow. If you can allow the norm to get longer you wil...

1 year ago | 0

Answered

How to measure angle of intersection ?

Assuming that the two lines are defined by four points P1, P2, P3, and P4 as such, the first line is L1(P1,P2) and the second li...

How to measure angle of intersection ?

Assuming that the two lines are defined by four points P1, P2, P3, and P4 as such, the first line is L1(P1,P2) and the second li...

1 year ago | 0

| accepted

Answered

How to train a data for binary classification using svm classifier

See the following page which explains SVMs and provides many examples on classification problems. https://www.mathworks.com/hel...

How to train a data for binary classification using svm classifier

See the following page which explains SVMs and provides many examples on classification problems. https://www.mathworks.com/hel...

1 year ago | 0

| accepted

Answered

if else nested loops

The problem is not with the if-else statments (although they are not correctly used). You need to assign the new values to x and...

if else nested loops

The problem is not with the if-else statments (although they are not correctly used). You need to assign the new values to x and...

1 year ago | 0

Answered

Why I am getting error message when I try to define line specs of a plot?

This will solve the problem. p = plot(fit1,'k-'); p.LineWidth = 2;

Why I am getting error message when I try to define line specs of a plot?

This will solve the problem. p = plot(fit1,'k-'); p.LineWidth = 2;

1 year ago | 0

Answered

Creating a matrix of ones and zeros with location of ones based on array value

The best solution I can think of is to use a for loop but will be faster than the one you showed because it will do one scalar a...

Creating a matrix of ones and zeros with location of ones based on array value

The best solution I can think of is to use a for loop but will be faster than the one you showed because it will do one scalar a...

1 year ago | 1

Answered

Please help extract variables from mat files and plot

load('site1.1.mat'); site1 = site; load('site1.2.mat'); site2 = site; figure; plot(site1.freq, site1.zxy, 'DisplayName', ...

Please help extract variables from mat files and plot

load('site1.1.mat'); site1 = site; load('site1.2.mat'); site2 = site; figure; plot(site1.freq, site1.zxy, 'DisplayName', ...

1 year ago | 0

| accepted

Answered

How to measure angle between two lines?

P1 = [1,1]; P2 = [5,5]; P3 = [5,2]; P4 = [1,3]; xL1 = P1(1)-P2(1); xL2 = P3(1)-P4(1); yL1 = P1(2)-P2(2); yL2 = P3(2)-P4(2...

How to measure angle between two lines?

P1 = [1,1]; P2 = [5,5]; P3 = [5,2]; P4 = [1,3]; xL1 = P1(1)-P2(1); xL2 = P3(1)-P4(1); yL1 = P1(2)-P2(2); yL2 = P3(2)-P4(2...

1 year ago | 1

Answered

Plot with Multiple x-Axes and y-Axes using the fill function

It seems Matlab is resetting ax2 settings to default after the fill command. add this line after the fill command to set them a...

Plot with Multiple x-Axes and y-Axes using the fill function

It seems Matlab is resetting ax2 settings to default after the fill command. add this line after the fill command to set them a...

1 year ago | 0

| accepted

Answered

extract all the data from a nested cell array with different size

cell2mat([yourcellarr{:}])

extract all the data from a nested cell array with different size

cell2mat([yourcellarr{:}])

1 year ago | 0

| accepted

Answered

Add s.f. to variable

I guess you mean by s.f. the format string in the sprintf function which is '%.2f' in your example. There is a way to specify v...

Add s.f. to variable

I guess you mean by s.f. the format string in the sprintf function which is '%.2f' in your example. There is a way to specify v...

1 year ago | 0

Answered

Legend issue: not all the entrties are shown.

You can only add one legend to the axis. So to solve your problem put all the names in one legend call. You may modify your code...

Legend issue: not all the entrties are shown.

You can only add one legend to the axis. So to solve your problem put all the names in one legend call. You may modify your code...

1 year ago | 0

| accepted

Answered

"Error using save Must be a string scalar or character vector." - but it is a string!

You need to enclose the variable names with qoutations like this: save(['data/test',num2str(n),'.mat'],'U','U_old','dt');

"Error using save Must be a string scalar or character vector." - but it is a string!

You need to enclose the variable names with qoutations like this: save(['data/test',num2str(n),'.mat'],'U','U_old','dt');

1 year ago | 4

| accepted

Answered

Divide your plot to four quarters and plot each of the four curves in a separate quarter of the plot.

The only way to create multiple plots in a figure is to use subplots as mentioned by per isakson You need to decide how to div...

Divide your plot to four quarters and plot each of the four curves in a separate quarter of the plot.

The only way to create multiple plots in a figure is to use subplots as mentioned by per isakson You need to decide how to div...

1 year ago | 1

| accepted

Answered

How to plot all the points between two lines?

It seems that you have an area inside a parallelogram defined by four points. Then you can use the inpolygon method as follows: ...

How to plot all the points between two lines?

It seems that you have an area inside a parallelogram defined by four points. Then you can use the inpolygon method as follows: ...

1 year ago | 1

| accepted

Answered

Saving mutiple files as structs

Asuming you get the files in cell array called "files", you can run the following loop to build the struct array "s_files" you w...

Saving mutiple files as structs

Asuming you get the files in cell array called "files", you can run the following loop to build the struct array "s_files" you w...

1 year ago | 0