Tag Archives: matlab
Program to Change the least number of a given Matrix Elements to get a condition on the sum of the numbers from collated row digits of the Matrix
I have a given Matrix A=k x n (k rows and n columns), with all elements digits in base 4,(can be only {0,1,2,3}). I want to write a program to change for any input matrix A to a new output B matrix respecting a condition. The condition is to change the least number of elements of A to form a modified matrix B(which keeps all the other unchanged elements of A), such that the k numbers of the row collated digits summed in base 4, are a multiple of (4^n)-1, expressed in base 4(n the number of columns of A and B)(The multiple must be the one such that B differs with the minimum nr of elements from A). Note that (4^n)-1 in base 4 is a row of n digits all 3s(3333…33, n times) . (4^3)-1 in base 4 = 333, However, a multiple of (4^3)-1, for instance [5*(4^3)-1] in base 4= 10323.
%I will give just an Example of a matrix A=3×6, k=3, n=6
A= [3,3,3,2,2,2; 3,2,3,3,1,2; 3,1,0,1,3,2]
%Convert row collated digits to numbers then to decimal
base2base(‘333222’,4,10)
base2base(‘323312’,4,10)
base2base(‘310132’,4,10)
%ans = ‘4074’
%ans = ‘3830’
%ans = ‘3358’
%Calculate their sum in base 10 of row digits 3 numbers
S=4074+3830+3358
%S = 11262
%Calculate (4^6) – 1 in decimal
(4^6) – 1
%4095
% One can see that a multiple of 2 of (4^6) – 1=8190, which can be expressed in base 4 , and is close to S
base2base(‘8190’,10,4)
%ans = ‘1333332’
%To get this row digits sum just one element change is sufficient, change element of A (2,1)=3 to B(2,1)=0, hence B is
B= [3,3,3,2,2,2; 0,2,3,3,1,2; 3,1,0,1,3,2]
base2base(‘333222’,4,10)
base2base(‘023312’,4,10)
base2base(‘310132’,4,10)
%ans = ‘4074’
%ans = ‘758’
%ans = ‘3358’
%Sum all in decimal to check if it is in base 4
S2=4074+758+3358
%S2 = 8190
% Which is the sought result. The program should be able to do such conversions of A to B for any input AI have a given Matrix A=k x n (k rows and n columns), with all elements digits in base 4,(can be only {0,1,2,3}). I want to write a program to change for any input matrix A to a new output B matrix respecting a condition. The condition is to change the least number of elements of A to form a modified matrix B(which keeps all the other unchanged elements of A), such that the k numbers of the row collated digits summed in base 4, are a multiple of (4^n)-1, expressed in base 4(n the number of columns of A and B)(The multiple must be the one such that B differs with the minimum nr of elements from A). Note that (4^n)-1 in base 4 is a row of n digits all 3s(3333…33, n times) . (4^3)-1 in base 4 = 333, However, a multiple of (4^3)-1, for instance [5*(4^3)-1] in base 4= 10323.
%I will give just an Example of a matrix A=3×6, k=3, n=6
A= [3,3,3,2,2,2; 3,2,3,3,1,2; 3,1,0,1,3,2]
%Convert row collated digits to numbers then to decimal
base2base(‘333222’,4,10)
base2base(‘323312’,4,10)
base2base(‘310132’,4,10)
%ans = ‘4074’
%ans = ‘3830’
%ans = ‘3358’
%Calculate their sum in base 10 of row digits 3 numbers
S=4074+3830+3358
%S = 11262
%Calculate (4^6) – 1 in decimal
(4^6) – 1
%4095
% One can see that a multiple of 2 of (4^6) – 1=8190, which can be expressed in base 4 , and is close to S
base2base(‘8190’,10,4)
%ans = ‘1333332’
%To get this row digits sum just one element change is sufficient, change element of A (2,1)=3 to B(2,1)=0, hence B is
B= [3,3,3,2,2,2; 0,2,3,3,1,2; 3,1,0,1,3,2]
base2base(‘333222’,4,10)
base2base(‘023312’,4,10)
base2base(‘310132’,4,10)
%ans = ‘4074’
%ans = ‘758’
%ans = ‘3358’
%Sum all in decimal to check if it is in base 4
S2=4074+758+3358
%S2 = 8190
% Which is the sought result. The program should be able to do such conversions of A to B for any input A I have a given Matrix A=k x n (k rows and n columns), with all elements digits in base 4,(can be only {0,1,2,3}). I want to write a program to change for any input matrix A to a new output B matrix respecting a condition. The condition is to change the least number of elements of A to form a modified matrix B(which keeps all the other unchanged elements of A), such that the k numbers of the row collated digits summed in base 4, are a multiple of (4^n)-1, expressed in base 4(n the number of columns of A and B)(The multiple must be the one such that B differs with the minimum nr of elements from A). Note that (4^n)-1 in base 4 is a row of n digits all 3s(3333…33, n times) . (4^3)-1 in base 4 = 333, However, a multiple of (4^3)-1, for instance [5*(4^3)-1] in base 4= 10323.
%I will give just an Example of a matrix A=3×6, k=3, n=6
A= [3,3,3,2,2,2; 3,2,3,3,1,2; 3,1,0,1,3,2]
%Convert row collated digits to numbers then to decimal
base2base(‘333222’,4,10)
base2base(‘323312’,4,10)
base2base(‘310132’,4,10)
%ans = ‘4074’
%ans = ‘3830’
%ans = ‘3358’
%Calculate their sum in base 10 of row digits 3 numbers
S=4074+3830+3358
%S = 11262
%Calculate (4^6) – 1 in decimal
(4^6) – 1
%4095
% One can see that a multiple of 2 of (4^6) – 1=8190, which can be expressed in base 4 , and is close to S
base2base(‘8190’,10,4)
%ans = ‘1333332’
%To get this row digits sum just one element change is sufficient, change element of A (2,1)=3 to B(2,1)=0, hence B is
B= [3,3,3,2,2,2; 0,2,3,3,1,2; 3,1,0,1,3,2]
base2base(‘333222’,4,10)
base2base(‘023312’,4,10)
base2base(‘310132’,4,10)
%ans = ‘4074’
%ans = ‘758’
%ans = ‘3358’
%Sum all in decimal to check if it is in base 4
S2=4074+758+3358
%S2 = 8190
% Which is the sought result. The program should be able to do such conversions of A to B for any input A min matrix elements change on condition MATLAB Answers — New Questions
How do I get DQN to output the policy I want
I’m solving a problem with DQN. This environment currently has 10 optional moves, 8 states, and 20 rounds per run. I want to keep my problem variables to a minimum. The optimaI’m solving a problem with DQN. This environment currently has 10 optional moves, 8 states, and 20 rounds per run. I want to keep my problem variables to a minimum. The optima I’m solving a problem with DQN. This environment currently has 10 optional moves, 8 states, and 20 rounds per run. I want to keep my problem variables to a minimum. The optima dqn MATLAB Answers — New Questions
How to increase the velocity of high-fidelity-plant multirotor in uavpackagedelivery
I used the uavpackagedelivery example to let a multirotor uav follow some waypoints. The problem is that, no matter how much i change the PID controller attributes of the velocity and position control and therefore the pitch and roll control in the control system of the high fidelity plant, the uav is flying way to slow, while it flies pretty fast with the low fidelity plant. The only way to increase the speed is by increasing the LookaheadDistance at the waypointfollower block. But that ruins the desired flightpath.
Is there any other way to let the uav fly faster without having to increase the lookaheaddistance?I used the uavpackagedelivery example to let a multirotor uav follow some waypoints. The problem is that, no matter how much i change the PID controller attributes of the velocity and position control and therefore the pitch and roll control in the control system of the high fidelity plant, the uav is flying way to slow, while it flies pretty fast with the low fidelity plant. The only way to increase the speed is by increasing the LookaheadDistance at the waypointfollower block. But that ruins the desired flightpath.
Is there any other way to let the uav fly faster without having to increase the lookaheaddistance? I used the uavpackagedelivery example to let a multirotor uav follow some waypoints. The problem is that, no matter how much i change the PID controller attributes of the velocity and position control and therefore the pitch and roll control in the control system of the high fidelity plant, the uav is flying way to slow, while it flies pretty fast with the low fidelity plant. The only way to increase the speed is by increasing the LookaheadDistance at the waypointfollower block. But that ruins the desired flightpath.
Is there any other way to let the uav fly faster without having to increase the lookaheaddistance? multirotor, simulink, uav, aerospace MATLAB Answers — New Questions
how to filter data based on one value in a column?
how to filter data based on one value in a column. i have 40000 rows and 4 columns. in 4th column i have values 1, 2, 3, 4. i want to filter all records in which the values of the 4th column should only be 3. the data is 40000 X 4 double type.how to filter data based on one value in a column. i have 40000 rows and 4 columns. in 4th column i have values 1, 2, 3, 4. i want to filter all records in which the values of the 4th column should only be 3. the data is 40000 X 4 double type. how to filter data based on one value in a column. i have 40000 rows and 4 columns. in 4th column i have values 1, 2, 3, 4. i want to filter all records in which the values of the 4th column should only be 3. the data is 40000 X 4 double type. filter data based on one value in a column MATLAB Answers — New Questions
Doubts regarding MATLAB Fundamentals-self paced Course Topic
sir,
In the topic of Matrix Multiplications, regarding Modeling Loons Populations, how the eleements of Population change matrix named as popChange are formed and loons population row matrix elements are also how are they formed. Can you please clarify my doubts.sir,
In the topic of Matrix Multiplications, regarding Modeling Loons Populations, how the eleements of Population change matrix named as popChange are formed and loons population row matrix elements are also how are they formed. Can you please clarify my doubts. sir,
In the topic of Matrix Multiplications, regarding Modeling Loons Populations, how the eleements of Population change matrix named as popChange are formed and loons population row matrix elements are also how are they formed. Can you please clarify my doubts. matlab fundamentals self paced course MATLAB Answers — New Questions
Fill in the missing time stamps in measurment data when the system is runnign but not when the system was OFF
Hello everyone,
I have 3 measurements in 3 excel sheets, each having two columns : Time stamp, State
The data is more or less continuously recorded (with different time resolution in 3 sheets) when the system was running and is discontinuous when the system was OFF.
What i want is for all the time stamps to match each other so that i can do my analysis.
I tried to import it in Matlab, and match the time stamps. I got some results by making the whole data continuous (i.e. filling in the missing time stamps). However this is not what i want as i would like to keep the discontinuity when the system was OFF so that the histogram data doesnt count unnecessary information.
I have attached a portion of the 3 excel sheets for example (In the raw data the discontinuity also happens for DAY as the system was turned OFF at night).
As one can see Data1.xlsx has the best time resolution and i would like if Data2 and Data3 could also match this time by filling in the missing points. However one can also see that there is a huge discontinuity between 12:53 and 14:01 which i would like to keep that way.
I kindly request someone to help me with this problem.Hello everyone,
I have 3 measurements in 3 excel sheets, each having two columns : Time stamp, State
The data is more or less continuously recorded (with different time resolution in 3 sheets) when the system was running and is discontinuous when the system was OFF.
What i want is for all the time stamps to match each other so that i can do my analysis.
I tried to import it in Matlab, and match the time stamps. I got some results by making the whole data continuous (i.e. filling in the missing time stamps). However this is not what i want as i would like to keep the discontinuity when the system was OFF so that the histogram data doesnt count unnecessary information.
I have attached a portion of the 3 excel sheets for example (In the raw data the discontinuity also happens for DAY as the system was turned OFF at night).
As one can see Data1.xlsx has the best time resolution and i would like if Data2 and Data3 could also match this time by filling in the missing points. However one can also see that there is a huge discontinuity between 12:53 and 14:01 which i would like to keep that way.
I kindly request someone to help me with this problem. Hello everyone,
I have 3 measurements in 3 excel sheets, each having two columns : Time stamp, State
The data is more or less continuously recorded (with different time resolution in 3 sheets) when the system was running and is discontinuous when the system was OFF.
What i want is for all the time stamps to match each other so that i can do my analysis.
I tried to import it in Matlab, and match the time stamps. I got some results by making the whole data continuous (i.e. filling in the missing time stamps). However this is not what i want as i would like to keep the discontinuity when the system was OFF so that the histogram data doesnt count unnecessary information.
I have attached a portion of the 3 excel sheets for example (In the raw data the discontinuity also happens for DAY as the system was turned OFF at night).
As one can see Data1.xlsx has the best time resolution and i would like if Data2 and Data3 could also match this time by filling in the missing points. However one can also see that there is a huge discontinuity between 12:53 and 14:01 which i would like to keep that way.
I kindly request someone to help me with this problem. time series MATLAB Answers — New Questions
Why circuit breaker in simulink/simscape is not working when open circuit condition?
Post Content Post Content breaker, simscape MATLAB Answers — New Questions
How to Use sort to Sort an Array of Custom Class Objects in MATLAB?
I have already overloaded the eq, lt, and gt methods in my class definition, but I am still encountering an issue when trying to sort using the sort function.
error sort
Incorrect number or types of inputs or outputs for function sort.I have already overloaded the eq, lt, and gt methods in my class definition, but I am still encountering an issue when trying to sort using the sort function.
error sort
Incorrect number or types of inputs or outputs for function sort. I have already overloaded the eq, lt, and gt methods in my class definition, but I am still encountering an issue when trying to sort using the sort function.
error sort
Incorrect number or types of inputs or outputs for function sort. sort, class MATLAB Answers — New Questions
How to get chaos features from a set of signals to build a ML classifier based on it?
I have a set of only two categorise time series signals and my supervisor asked me to get the chaos features from it:
he told me first to get the hilbert huang transform, the get the chaos features from its output, but I coulden’t fined how to do thisI have a set of only two categorise time series signals and my supervisor asked me to get the chaos features from it:
he told me first to get the hilbert huang transform, the get the chaos features from its output, but I coulden’t fined how to do this I have a set of only two categorise time series signals and my supervisor asked me to get the chaos features from it:
he told me first to get the hilbert huang transform, the get the chaos features from its output, but I coulden’t fined how to do this machine learning, deep learning, time series, classification, dsp, digital signal processing MATLAB Answers — New Questions
Generating triangle wave form
Hi everyone!
I was wondering how can i generate a triangle wave form? I don’t want to use the pre-prepared block with simulink for this purpose (I want to generate code from it which is effective). I know if i integrate a square wave form i can get the triangle wave form but at that case i have to generate a square wave.
Any ideas or help would be nice
Thanks for the answers.Hi everyone!
I was wondering how can i generate a triangle wave form? I don’t want to use the pre-prepared block with simulink for this purpose (I want to generate code from it which is effective). I know if i integrate a square wave form i can get the triangle wave form but at that case i have to generate a square wave.
Any ideas or help would be nice
Thanks for the answers. Hi everyone!
I was wondering how can i generate a triangle wave form? I don’t want to use the pre-prepared block with simulink for this purpose (I want to generate code from it which is effective). I know if i integrate a square wave form i can get the triangle wave form but at that case i have to generate a square wave.
Any ideas or help would be nice
Thanks for the answers. triangle wave form, generating wave form, simulink MATLAB Answers — New Questions
Unable to run rtwmakecfg file. Insufficient number of outputs
When building a model using a speedgoat blockset with Simulink Real Time, I receive the following error. "Insufficient number of outputs from right hand side of equal sign to satisfy assignment"
I am unsure what causes this or how to resolve it.When building a model using a speedgoat blockset with Simulink Real Time, I receive the following error. "Insufficient number of outputs from right hand side of equal sign to satisfy assignment"
I am unsure what causes this or how to resolve it. When building a model using a speedgoat blockset with Simulink Real Time, I receive the following error. "Insufficient number of outputs from right hand side of equal sign to satisfy assignment"
I am unsure what causes this or how to resolve it. speedgoat, matlab, coder, simulink, realtime MATLAB Answers — New Questions
inaccessible input in Test Harness (Simulink Test)
I am getting ‘inaccessible’ for some of the inputs when performing MIL testing in Testsequence.I am getting ‘inaccessible’ for some of the inputs when performing MIL testing in Testsequence. I am getting ‘inaccessible’ for some of the inputs when performing MIL testing in Testsequence. inaccessible inputs MATLAB Answers — New Questions
In MATLAB I get the following python error: AttributeError: ‘module’ object has no attribute ‘fmi’
When I call my custom python function py.linFMI.run() in MATLAB R2016a I get the following error:
Error using fmi_algorithm_drivers><module> (line 28)
Python Error: AttributeError: ‘module’ object has no attribute ‘fmi’
Error in fmi>pyfmi.fmi.ModelBase._default_options (srcpyfmifmi.c:6394) (line 338)
Error in fmi>pyfmi.fmi.FMUModelME2.simulate_options (srcpyfmifmi.c:65521) (line 6515)
Error in linFMI>run (line 313)
opts=model.simulate_options()
The same function works fine in a windows or IPython console. Any ideas what is going wrong?When I call my custom python function py.linFMI.run() in MATLAB R2016a I get the following error:
Error using fmi_algorithm_drivers><module> (line 28)
Python Error: AttributeError: ‘module’ object has no attribute ‘fmi’
Error in fmi>pyfmi.fmi.ModelBase._default_options (srcpyfmifmi.c:6394) (line 338)
Error in fmi>pyfmi.fmi.FMUModelME2.simulate_options (srcpyfmifmi.c:65521) (line 6515)
Error in linFMI>run (line 313)
opts=model.simulate_options()
The same function works fine in a windows or IPython console. Any ideas what is going wrong? When I call my custom python function py.linFMI.run() in MATLAB R2016a I get the following error:
Error using fmi_algorithm_drivers><module> (line 28)
Python Error: AttributeError: ‘module’ object has no attribute ‘fmi’
Error in fmi>pyfmi.fmi.ModelBase._default_options (srcpyfmifmi.c:6394) (line 338)
Error in fmi>pyfmi.fmi.FMUModelME2.simulate_options (srcpyfmifmi.c:65521) (line 6515)
Error in linFMI>run (line 313)
opts=model.simulate_options()
The same function works fine in a windows or IPython console. Any ideas what is going wrong? python-2.7, pyfmi, interface, python MATLAB Answers — New Questions
How to make bold font for axis labe with latex interpreter
Hey i try to make my axis label that contain latex interpreter in bold style. I have try some suggestion befor but none of them seems to works. Anybody have a clue?
This is my line
ylabel(‘$|frac{ddot{X}(iomega)_{2}}{F(iomega)_{4}}|$ ($frac{mm/s^2}{N}$)’, ‘Interpreter’,’Latex’)Hey i try to make my axis label that contain latex interpreter in bold style. I have try some suggestion befor but none of them seems to works. Anybody have a clue?
This is my line
ylabel(‘$|frac{ddot{X}(iomega)_{2}}{F(iomega)_{4}}|$ ($frac{mm/s^2}{N}$)’, ‘Interpreter’,’Latex’) Hey i try to make my axis label that contain latex interpreter in bold style. I have try some suggestion befor but none of them seems to works. Anybody have a clue?
This is my line
ylabel(‘$|frac{ddot{X}(iomega)_{2}}{F(iomega)_{4}}|$ ($frac{mm/s^2}{N}$)’, ‘Interpreter’,’Latex’) latex interpreter, bold MATLAB Answers — New Questions
Import and Read data with several sheets
Hello Everyone,
I am trying to use the line of code below to read my matrix data from an excel file. However, I get stuck from the the 2nd line of code, which takes forever to run and not complete. I am wondering if I am doing something wrong. Can some help with advice?
[~,sheet_name]=xlsfinfo(‘Gas.xlsx’);
for k=1:numel(sheet_name)
data{k}=readmatrix(‘Gas.xlsx’,’Sheet’,sheet_name{k},’Range’,’A2:IP176′);
endHello Everyone,
I am trying to use the line of code below to read my matrix data from an excel file. However, I get stuck from the the 2nd line of code, which takes forever to run and not complete. I am wondering if I am doing something wrong. Can some help with advice?
[~,sheet_name]=xlsfinfo(‘Gas.xlsx’);
for k=1:numel(sheet_name)
data{k}=readmatrix(‘Gas.xlsx’,’Sheet’,sheet_name{k},’Range’,’A2:IP176′);
end Hello Everyone,
I am trying to use the line of code below to read my matrix data from an excel file. However, I get stuck from the the 2nd line of code, which takes forever to run and not complete. I am wondering if I am doing something wrong. Can some help with advice?
[~,sheet_name]=xlsfinfo(‘Gas.xlsx’);
for k=1:numel(sheet_name)
data{k}=readmatrix(‘Gas.xlsx’,’Sheet’,sheet_name{k},’Range’,’A2:IP176′);
end matrix excel, 3d plot MATLAB Answers — New Questions
determine optimal p for AR model
hi i wanna determine AR model p using PACF
in this plot how can i determine optimal p? it seems not convergedhi i wanna determine AR model p using PACF
in this plot how can i determine optimal p? it seems not converged hi i wanna determine AR model p using PACF
in this plot how can i determine optimal p? it seems not converged pacf, ar model, optimal p MATLAB Answers — New Questions
How to create a dialog box in the plot window.
As a personal project, I have been writing a game engine in Matlab. It will be a sort of text-based RPG, where you input your command into a text box and then the game interprets that. Right now, this is the state of my getCommand function:
function GetCommand(n)
sprintf("GetCommand %d", n)
pause(0.1)
String = input(‘Input n’, ‘s’);
String = split(String);
Command = String{1,1};
Subject = String{2,1};
switch command
case ‘go’
go(subject)
end
The idea is to run Command through a switch function to find that command, and run the command using Subject as its argument.
It currently works well enough. However, the input function requests input directly from Matlab’s command line. I would like to request input from the plot window, which is where I’m rendering the game. I found inputdlg(), but that creates an entirely new window, which is not what I want either.
I hope I made myself clear. Is there any way to create a dialog box within the plot window?As a personal project, I have been writing a game engine in Matlab. It will be a sort of text-based RPG, where you input your command into a text box and then the game interprets that. Right now, this is the state of my getCommand function:
function GetCommand(n)
sprintf("GetCommand %d", n)
pause(0.1)
String = input(‘Input n’, ‘s’);
String = split(String);
Command = String{1,1};
Subject = String{2,1};
switch command
case ‘go’
go(subject)
end
The idea is to run Command through a switch function to find that command, and run the command using Subject as its argument.
It currently works well enough. However, the input function requests input directly from Matlab’s command line. I would like to request input from the plot window, which is where I’m rendering the game. I found inputdlg(), but that creates an entirely new window, which is not what I want either.
I hope I made myself clear. Is there any way to create a dialog box within the plot window? As a personal project, I have been writing a game engine in Matlab. It will be a sort of text-based RPG, where you input your command into a text box and then the game interprets that. Right now, this is the state of my getCommand function:
function GetCommand(n)
sprintf("GetCommand %d", n)
pause(0.1)
String = input(‘Input n’, ‘s’);
String = split(String);
Command = String{1,1};
Subject = String{2,1};
switch command
case ‘go’
go(subject)
end
The idea is to run Command through a switch function to find that command, and run the command using Subject as its argument.
It currently works well enough. However, the input function requests input directly from Matlab’s command line. I would like to request input from the plot window, which is where I’m rendering the game. I found inputdlg(), but that creates an entirely new window, which is not what I want either.
I hope I made myself clear. Is there any way to create a dialog box within the plot window? user input, string, plot window, plotting, dialog box MATLAB Answers — New Questions
Extract Data from Table by Data Values
Hi all,
I am trying to extract rows matching one of multiple values but I am not sure which functions to use. I have a 9,857,445 x 3 table. The headers are in the 3 columns, and all 3 columns A,B, C, contain numerical data.
I am trying to extract based on data for the first column A. For example, I want to extract the rows that have the following values for A; A= 1, A=6, A=4 or A =12. Based on all the rows that match any of the possible listed values for A, I would like to create a new table Final Data, that only lists rows that match the given values for A. I am using 2015a.
Thanks for your help.Hi all,
I am trying to extract rows matching one of multiple values but I am not sure which functions to use. I have a 9,857,445 x 3 table. The headers are in the 3 columns, and all 3 columns A,B, C, contain numerical data.
I am trying to extract based on data for the first column A. For example, I want to extract the rows that have the following values for A; A= 1, A=6, A=4 or A =12. Based on all the rows that match any of the possible listed values for A, I would like to create a new table Final Data, that only lists rows that match the given values for A. I am using 2015a.
Thanks for your help. Hi all,
I am trying to extract rows matching one of multiple values but I am not sure which functions to use. I have a 9,857,445 x 3 table. The headers are in the 3 columns, and all 3 columns A,B, C, contain numerical data.
I am trying to extract based on data for the first column A. For example, I want to extract the rows that have the following values for A; A= 1, A=6, A=4 or A =12. Based on all the rows that match any of the possible listed values for A, I would like to create a new table Final Data, that only lists rows that match the given values for A. I am using 2015a.
Thanks for your help. table, data MATLAB Answers — New Questions
I’m getting a new line (without adding n) and an indented line when using the function input() (MATLAB Online)
Hello,
I have been trying to read the input from the user using the input function as shown below.
function open_webpage
url = input("Enter the url: ", "s");
while isempty(url)
fprintf("You didn’t enter any url. Please try again.n")
url = input("Enter the url: ", "s");
end
end
The function works fine so far. However, when I run it, I keep getting a new line when prompted to enter the URL as shown below. Also, I don’t understand why is the text indented.
I even checked the documentation and it seems I did everything correctly. Am I missing something?Hello,
I have been trying to read the input from the user using the input function as shown below.
function open_webpage
url = input("Enter the url: ", "s");
while isempty(url)
fprintf("You didn’t enter any url. Please try again.n")
url = input("Enter the url: ", "s");
end
end
The function works fine so far. However, when I run it, I keep getting a new line when prompted to enter the URL as shown below. Also, I don’t understand why is the text indented.
I even checked the documentation and it seems I did everything correctly. Am I missing something? Hello,
I have been trying to read the input from the user using the input function as shown below.
function open_webpage
url = input("Enter the url: ", "s");
while isempty(url)
fprintf("You didn’t enter any url. Please try again.n")
url = input("Enter the url: ", "s");
end
end
The function works fine so far. However, when I run it, I keep getting a new line when prompted to enter the URL as shown below. Also, I don’t understand why is the text indented.
I even checked the documentation and it seems I did everything correctly. Am I missing something? input, n, matlab online MATLAB Answers — New Questions
problem with storing in an array
% The previous code was omitted
% Part of the code for the preliminary detection of extreme points
num = 0;
extreme_point = [];
for oct_i = 1 : octave
dog = dog_pyr{oct_i};
[dog_r, dog_c, dog_page] = size(dog);
for r = 6 : dog_r – 5
for c = 6 : dog_c – 5
for page_i = 2 : dog_page – 1
dog_near = zeros(3, 3, 3);
dog_near(:, :, 1) = dog(r – 1 : r + 1, c – 1 : c + 1, page_i – 1);
dog_near(:, :, 2) = dog(r – 1 : r + 1, c – 1 : c + 1, page_i);
dog_near(:, :, 3) = dog(r – 1 : r + 1, c – 1 : c + 1, page_i + 1);
point_vale = dog_near(2, 2, 2);
if (point_vale == max(dog_near(:))) || (point_vale == min(dog_near(:)))
num = num +1;
sigma_i = k ^ (page_i -1) * sigma0;
extreme_point(num, 🙂 = [oct_i, page_i, r, c, sigma_i, 0]; % ???
end
end
end
end
end
hi, I’d like to ask you a questio, about the last line "extreme_point(num, 🙂 = [oct_i, page_i, r, c, sigma_i, 0];", Pls if it is written "extreme_point(num) = [oct_i, page_i, r, c, sigma_i, 0];", an error message that the assignment cannot be performed because the index on the left is incompatible with the size on the right will appear.
May I ask why this error occurs?
At the beginning of learning not quite understand, this is about the sift algorithm part of the content, the overall problem is all machine rollover, please understand.% The previous code was omitted
% Part of the code for the preliminary detection of extreme points
num = 0;
extreme_point = [];
for oct_i = 1 : octave
dog = dog_pyr{oct_i};
[dog_r, dog_c, dog_page] = size(dog);
for r = 6 : dog_r – 5
for c = 6 : dog_c – 5
for page_i = 2 : dog_page – 1
dog_near = zeros(3, 3, 3);
dog_near(:, :, 1) = dog(r – 1 : r + 1, c – 1 : c + 1, page_i – 1);
dog_near(:, :, 2) = dog(r – 1 : r + 1, c – 1 : c + 1, page_i);
dog_near(:, :, 3) = dog(r – 1 : r + 1, c – 1 : c + 1, page_i + 1);
point_vale = dog_near(2, 2, 2);
if (point_vale == max(dog_near(:))) || (point_vale == min(dog_near(:)))
num = num +1;
sigma_i = k ^ (page_i -1) * sigma0;
extreme_point(num, 🙂 = [oct_i, page_i, r, c, sigma_i, 0]; % ???
end
end
end
end
end
hi, I’d like to ask you a questio, about the last line "extreme_point(num, 🙂 = [oct_i, page_i, r, c, sigma_i, 0];", Pls if it is written "extreme_point(num) = [oct_i, page_i, r, c, sigma_i, 0];", an error message that the assignment cannot be performed because the index on the left is incompatible with the size on the right will appear.
May I ask why this error occurs?
At the beginning of learning not quite understand, this is about the sift algorithm part of the content, the overall problem is all machine rollover, please understand. % The previous code was omitted
% Part of the code for the preliminary detection of extreme points
num = 0;
extreme_point = [];
for oct_i = 1 : octave
dog = dog_pyr{oct_i};
[dog_r, dog_c, dog_page] = size(dog);
for r = 6 : dog_r – 5
for c = 6 : dog_c – 5
for page_i = 2 : dog_page – 1
dog_near = zeros(3, 3, 3);
dog_near(:, :, 1) = dog(r – 1 : r + 1, c – 1 : c + 1, page_i – 1);
dog_near(:, :, 2) = dog(r – 1 : r + 1, c – 1 : c + 1, page_i);
dog_near(:, :, 3) = dog(r – 1 : r + 1, c – 1 : c + 1, page_i + 1);
point_vale = dog_near(2, 2, 2);
if (point_vale == max(dog_near(:))) || (point_vale == min(dog_near(:)))
num = num +1;
sigma_i = k ^ (page_i -1) * sigma0;
extreme_point(num, 🙂 = [oct_i, page_i, r, c, sigma_i, 0]; % ???
end
end
end
end
end
hi, I’d like to ask you a questio, about the last line "extreme_point(num, 🙂 = [oct_i, page_i, r, c, sigma_i, 0];", Pls if it is written "extreme_point(num) = [oct_i, page_i, r, c, sigma_i, 0];", an error message that the assignment cannot be performed because the index on the left is incompatible with the size on the right will appear.
May I ask why this error occurs?
At the beginning of learning not quite understand, this is about the sift algorithm part of the content, the overall problem is all machine rollover, please understand. array,sift,if MATLAB Answers — New Questions