Answered

want to read 38 csv files only first and second column?

csvFile = dir("*.csv") ; N = length(csvFile) ; for i = 1:N data = readtable(csvFile(i).name) ; iwant = data.Point...

want to read 38 csv files only first and second column?

csvFile = dir("*.csv") ; N = length(csvFile) ; for i = 1:N data = readtable(csvFile(i).name) ; iwant = data.Point...

9 hours ago | 0

| accepted

Answered

How to first form a variable and then assign values to it?

Switch ..case can be one option. Var='Temperature'; switch Var case 'Temperature' Temperature=[1; 5; 3; 7]; ...

How to first form a variable and then assign values to it?

Switch ..case can be one option. Var='Temperature'; switch Var case 'Temperature' Temperature=[1; 5; 3; 7]; ...

10 hours ago | 0

Answered

Error using zeros, Size inputs must be scalar. Need help with this error in my function.

If you are inputing, Enter the length of the vector : 2 (any scalar value) then it will work m = zeros(1,length(ln)) 2....

Error using zeros, Size inputs must be scalar. Need help with this error in my function.

If you are inputing, Enter the length of the vector : 2 (any scalar value) then it will work m = zeros(1,length(ln)) 2....

11 hours ago | 0

Answered

How can I extract the usernames and hosts from a .txt file

You can use readtable to read text file into table format. file = 'data_file.txt'; opts = detectImportOptions(file ); T=readt...

How can I extract the usernames and hosts from a .txt file

You can use readtable to read text file into table format. file = 'data_file.txt'; opts = detectImportOptions(file ); T=readt...

11 hours ago | 0

| accepted

Answered

How do I plot specific data from an export excel file?

Example: Then you need plot of Value1 vs Value2 of country 'Canada' : table=readtable('test1.xlsx'); Data= contains((table...

How do I plot specific data from an export excel file?

Example: Then you need plot of Value1 vs Value2 of country 'Canada' : table=readtable('test1.xlsx'); Data= contains((table...

12 hours ago | 0

Answered

Matlab Function find sum of Euclidean distances from a given 2-D point

Use docsearch 'Euclidean'. https://www.mathworks.com/help/releases/R2019b/matlab/ref/norm.html#bt0y64c-1 Use norm to calculate...

Matlab Function find sum of Euclidean distances from a given 2-D point

Use docsearch 'Euclidean'. https://www.mathworks.com/help/releases/R2019b/matlab/ref/norm.html#bt0y64c-1 Use norm to calculate...

14 hours ago | 0

Answered

one size image for CNN

You can checkout imresize function to make image sizes to be equal. https://www.mathworks.com/help/releases/R2019b/matlab/ref/i...

one size image for CNN

You can checkout imresize function to make image sizes to be equal. https://www.mathworks.com/help/releases/R2019b/matlab/ref/i...

14 hours ago | 1

| accepted

Answered

How to store data of FOR LOOP iteration?

You can use P_new(i) or P_new{i} to store loop result.

How to store data of FOR LOOP iteration?

You can use P_new(i) or P_new{i} to store loop result.

15 hours ago | 0

Answered

generating files using loop or other functions

Use readtable and writetable functions. Data=readtable('x1)Data.xlsx'); % Read excel data [R,C]=size(Data); % get number of co...

generating files using loop or other functions

Use readtable and writetable functions. Data=readtable('x1)Data.xlsx'); % Read excel data [R,C]=size(Data); % get number of co...

19 hours ago | 0

| accepted

Answered

How can I resize all images within a cell array?

This could work if your images are size of [MxNx3]: for i=1:length(image_content) ResImage{i}=imresize(image_content{i},[2...

How can I resize all images within a cell array?

This could work if your images are size of [MxNx3]: for i=1:length(image_content) ResImage{i}=imresize(image_content{i},[2...

20 hours ago | 0

| accepted

Answered

NaNs when reading from table

As there are empty fields within your csv file, MATLAB read it as NAN(not a number). Thought could be: Create a data in csv s...

NaNs when reading from table

As there are empty fields within your csv file, MATLAB read it as NAN(not a number). Thought could be: Create a data in csv s...

5 days ago | 0

Answered

Suggestion on what im doing wrong.

The 'min' function and for loop will help: A=[8 1 -2 9 5 11 6]; n=2; % Exclude 2 smallest elements for i=1:n [num,id]=min(...

Suggestion on what im doing wrong.

The 'min' function and for loop will help: A=[8 1 -2 9 5 11 6]; n=2; % Exclude 2 smallest elements for i=1:n [num,id]=min(...

5 days ago | 0

Answered

Convert patch Matlab to file STL

Check this: https://www.mathworks.com/help/releases/R2019b/matlab/ref/stlwrite.html https://www.mathworks.com/help/releases/R2...

Convert patch Matlab to file STL

Check this: https://www.mathworks.com/help/releases/R2019b/matlab/ref/stlwrite.html https://www.mathworks.com/help/releases/R2...

6 days ago | 0

| accepted

Answered

How to rearrange a cell array with a given index vector

change semicolon to comma to seperate 2 & 3 from id: idx = [2,3,1];

How to rearrange a cell array with a given index vector

change semicolon to comma to seperate 2 & 3 from id: idx = [2,3,1];

6 days ago | 0

| accepted

Answered

How to plot polar curve in both upper and lower half region?

Change Polar Axes Limits By default, negative values of the radius are plotted as positive values in the polar plot. Use rlim t...

How to plot polar curve in both upper and lower half region?

Change Polar Axes Limits By default, negative values of the radius are plotted as positive values in the polar plot. Use rlim t...

6 days ago | 0

Answered

changing the structure of a matrix according to a characteristic matrix

Use elementwise (.) operator : Xa=[0 1 1;0 0 1;1 1 1] b=[9 8 7;3 2 7;4 5 3] b.*Xa

changing the structure of a matrix according to a characteristic matrix

Use elementwise (.) operator : Xa=[0 1 1;0 0 1;1 1 1] b=[9 8 7;3 2 7;4 5 3] b.*Xa

6 days ago | 0

| accepted

Answered

how to import average and maximum data from excel sheet .

[~,Num,Data]=xlsread('solar02.xlsx'); %Average values greater than zero Average = mean(Data(2:end,3)>0); %Maximum max(Averag...

how to import average and maximum data from excel sheet .

[~,Num,Data]=xlsread('solar02.xlsx'); %Average values greater than zero Average = mean(Data(2:end,3)>0); %Maximum max(Averag...

8 days ago | 0

| accepted

Answered

Simulink Matlab Function Block Error

To run mex function you need c-compiler. simply open command window and type: mex -setup If c compiler is available this comma...

Simulink Matlab Function Block Error

To run mex function you need c-compiler. simply open command window and type: mex -setup If c compiler is available this comma...

12 days ago | 1

Answered

Transforming a script into a function with multiple inputs

%load data myfilename = 'Example.csv'; month = 1; trial(myfilename, month); function trial(myfilename, month) data=readta...

Transforming a script into a function with multiple inputs

%load data myfilename = 'Example.csv'; month = 1; trial(myfilename, month); function trial(myfilename, month) data=readta...

12 days ago | 0

| accepted

Answered

how do I apply an if statement to each row of a column vector?

Try this: R = [0.1:0.1:1]; step=zeros(1,length(R(:))); for n=1:length(R(:)) if R(n)<0.5 step(n)= -1; elsei...

how do I apply an if statement to each row of a column vector?

Try this: R = [0.1:0.1:1]; step=zeros(1,length(R(:))); for n=1:length(R(:)) if R(n)<0.5 step(n)= -1; elsei...

12 days ago | 0

| accepted

Answered

Loading in a for loop

You can use 'int2str' for i=1:400 run_i=['C:\Users\unknown\run_',int2str(i)]; end %or for i=1:400 run_i=strcat('C:...

Loading in a for loop

You can use 'int2str' for i=1:400 run_i=['C:\Users\unknown\run_',int2str(i)]; end %or for i=1:400 run_i=strcat('C:...

13 days ago | 0

Answered

Make a movie from series of Fig file

Try VideoWriter video = VideoWriter('Movie.avi'); open(video); folder = 'D\Folder'; str = int2str(i); for i=1:N Image...

Make a movie from series of Fig file

Try VideoWriter video = VideoWriter('Movie.avi'); open(video); folder = 'D\Folder'; str = int2str(i); for i=1:N Image...

13 days ago | 0

Answered

How to read multiple image directory with for loop

1 option could be: if i>9 str = strcat('\','image_00',str,'.png'); end

How to read multiple image directory with for loop

1 option could be: if i>9 str = strcat('\','image_00',str,'.png'); end

13 days ago | 0

| accepted

Answered

Nested If Statement HELP

Use elseif: prompt = ' enter a value between 0 and 100 ' ; x = input(prompt) ; if x >= 90 && x <= 100 disp (' Grade is A...

Nested If Statement HELP

Use elseif: prompt = ' enter a value between 0 and 100 ' ; x = input(prompt) ; if x >= 90 && x <= 100 disp (' Grade is A...

13 days ago | 0

Answered

Iteration output won't show in a plot

Try this: format long; disp('Number of Iterations Approximate Value') xData=1; n=1; fprintf('\n%d ...

Iteration output won't show in a plot

Try this: format long; disp('Number of Iterations Approximate Value') xData=1; n=1; fprintf('\n%d ...

13 days ago | 1

| accepted

Answered

Plot multiple histogram within 1 function

[~,ErrorLength]= size(out); for i =1:ErrorLength hold on histogram(out(:,i),'normalization','pdf') hold off end...

Plot multiple histogram within 1 function

[~,ErrorLength]= size(out); for i =1:ErrorLength hold on histogram(out(:,i),'normalization','pdf') hold off end...

13 days ago | 0

| accepted

Answered

How can I see all of toolboxes?

one option to see all toolboxes: Go to command window and type to list out all installed toolboxes on your machine. ver

How can I see all of toolboxes?

one option to see all toolboxes: Go to command window and type to list out all installed toolboxes on your machine. ver

13 days ago | 0

Answered

Running a for loop for a function across two variables

looks like your function is 2 input arguments and 2 output arguments: function [Tatm, Tsurf] = modelwithatm(lwabsorbedatm,surf...

Running a for loop for a function across two variables

looks like your function is 2 input arguments and 2 output arguments: function [Tatm, Tsurf] = modelwithatm(lwabsorbedatm,surf...

13 days ago | 0

Answered

Find maximum among the elements in the matrix lower than 80% of max element of entire matrix

%Try this: Result = A(A<(0.8*S))

Find maximum among the elements in the matrix lower than 80% of max element of entire matrix

%Try this: Result = A(A<(0.8*S))

13 days ago | 1

| accepted