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...

4 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(...

4 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...

5 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];

5 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...

5 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

5 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...

7 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...

11 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...

11 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...

11 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:...

11 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...

12 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

12 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...

12 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 ...

12 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...

12 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

12 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...

12 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))

12 days ago | 1

| accepted

Answered

How to check user input data using letters

you could try this: function HumanInputFxn(~) Good=0;%initilizes loop variable while Good<1 Letter_Input=input('Enter c...

How to check user input data using letters

you could try this: function HumanInputFxn(~) Good=0;%initilizes loop variable while Good<1 Letter_Input=input('Enter c...

13 days ago | 0

| accepted

Answered

How to overcome this error?

%Example: a=[1 2 3 4] B= [a;0] %This throws an eroor as you mentioned %Correct concatenation B=[a,0] %or B=[a';0]

How to overcome this error?

%Example: a=[1 2 3 4] B= [a;0] %This throws an eroor as you mentioned %Correct concatenation B=[a,0] %or B=[a';0]

13 days ago | 0

Answered

need to write values on contour plots

these examples may help you: %1 f = @(x,y) exp(-(x/3).^2-(y/3).^2) + exp(-(x+2).^2-(y+2).^2); fc = fcontour(f); fc.LineWidth...

need to write values on contour plots

these examples may help you: %1 f = @(x,y) exp(-(x/3).^2-(y/3).^2) + exp(-(x+2).^2-(y+2).^2); fc = fcontour(f); fc.LineWidth...

13 days ago | 0

Answered

How can I import data to simulink from the workspace

The data available in base workspace can access your simulink model during simulation. If you would like to provide timeseries ...

How can I import data to simulink from the workspace

The data available in base workspace can access your simulink model during simulation. If you would like to provide timeseries ...

13 days ago | 0

Answered

Classify imported files from multiple folders into cell array

You could try this example. load test.mat; folder={files.folder}; name = {files.name}; for i=1:6 Data{i} = name(conta...

Classify imported files from multiple folders into cell array

You could try this example. load test.mat; folder={files.folder}; name = {files.name}; for i=1:6 Data{i} = name(conta...

13 days ago | 0

Answered

values calculated from avector

exp fumcion is available in matlab. The s1 & s2 syntax you written can directly be used. s=[a b]; s1=exp(s(1)); s2=exp(s(2));...

values calculated from avector

exp fumcion is available in matlab. The s1 & s2 syntax you written can directly be used. s=[a b]; s1=exp(s(1)); s2=exp(s(2));...

14 days ago | 0

| accepted

Answered

How can I load bus objects in simulink base workspace?

Eg. If you have bus objects now in 'Dictionary.m' file, You can use 'PreaLoadFcn' function or 'PostLoadFcn' to load bus objects ...

How can I load bus objects in simulink base workspace?

Eg. If you have bus objects now in 'Dictionary.m' file, You can use 'PreaLoadFcn' function or 'PostLoadFcn' to load bus objects ...

14 days ago | 0

| accepted

Answered

Using loop to create multiple variables

you can try this: %b is a vector contains values from 1,2,3....to 16. b = 1:16; A=2; % A is a scalr whose value is 2 for i ...

Using loop to create multiple variables

you can try this: %b is a vector contains values from 1,2,3....to 16. b = 1:16; A=2; % A is a scalr whose value is 2 for i ...

14 days ago | 1

| accepted

Answered

Assigning a variable according to file name..

Example: Track = 2; File = 2; Filename = {}; for j=1:(File) for i = 1:(Track) Filename{end+1} = ['SimulationFi...

Assigning a variable according to file name..

Example: Track = 2; File = 2; Filename = {}; for j=1:(File) for i = 1:(Track) Filename{end+1} = ['SimulationFi...

15 days ago | 0

Answered

Why do I get NaN result?

Values within gradf function for n=32 becomes infinite ('inf') and hence results are NAN (Not a number).

Why do I get NaN result?

Values within gradf function for n=32 becomes infinite ('inf') and hence results are NAN (Not a number).

15 days ago | 0

Answered

How to modify the markers of a figure of the decaying function are squares instead of circle and set the line width of the other sinusoid to 2 instead of 4?

x = 0:pi/20:4*pi; plot(x, sin(x),'LineWidth',2) hold on plot(x, exp(-0.1*x).*sin(x),'s') hold off

How to modify the markers of a figure of the decaying function are squares instead of circle and set the line width of the other sinusoid to 2 instead of 4?

x = 0:pi/20:4*pi; plot(x, sin(x),'LineWidth',2) hold on plot(x, exp(-0.1*x).*sin(x),'s') hold off

15 days ago | 0

| accepted