Category: Matlab
Category Archives: Matlab
Can the MATLAB Installer save its download progress?
When I downloaded MATLAB with its Installer, halfway through the download, it said I couldn’t connect to the server, and it closed. when I opened it again, I needed to start from scratch and download again.When I downloaded MATLAB with its Installer, halfway through the download, it said I couldn’t connect to the server, and it closed. when I opened it again, I needed to start from scratch and download again. When I downloaded MATLAB with its Installer, halfway through the download, it said I couldn’t connect to the server, and it closed. when I opened it again, I needed to start from scratch and download again. installation, iso image MATLAB Answers — New Questions
Which estimator is used for which greyest options?
Hello Matlab folk,
this is my first entry in this forum, if I do something wrong, don’t hesitate to tell me.
I am wondering how i can determine, whether to use a Least Squares Estimator or a Maximum Likelihood Estimator. Is it the "Focus" setting or the "OutputWeight" in greyestOptions?
In literature, estimators are often characterized in Output-, Filter-, or Equation-Error. Which setting combinations correspond to those estimators?
Thank you very much,
MariusHello Matlab folk,
this is my first entry in this forum, if I do something wrong, don’t hesitate to tell me.
I am wondering how i can determine, whether to use a Least Squares Estimator or a Maximum Likelihood Estimator. Is it the "Focus" setting or the "OutputWeight" in greyestOptions?
In literature, estimators are often characterized in Output-, Filter-, or Equation-Error. Which setting combinations correspond to those estimators?
Thank you very much,
Marius Hello Matlab folk,
this is my first entry in this forum, if I do something wrong, don’t hesitate to tell me.
I am wondering how i can determine, whether to use a Least Squares Estimator or a Maximum Likelihood Estimator. Is it the "Focus" setting or the "OutputWeight" in greyestOptions?
In literature, estimators are often characterized in Output-, Filter-, or Equation-Error. Which setting combinations correspond to those estimators?
Thank you very much,
Marius greyest, greyestoptions, estimation, estimators, system identification MATLAB Answers — New Questions
Problem with NaNs for data analysis
I have a large data set on which I am doing some processing. I need to calculate mean for section s of data , but the problem is My data is having NaN values . due to which I am facing errors. can anyone help me how to het rid of this.I have a large data set on which I am doing some processing. I need to calculate mean for section s of data , but the problem is My data is having NaN values . due to which I am facing errors. can anyone help me how to het rid of this. I have a large data set on which I am doing some processing. I need to calculate mean for section s of data , but the problem is My data is having NaN values . due to which I am facing errors. can anyone help me how to het rid of this. matlab MATLAB Answers — New Questions
Problem in solving an optimization problem
Hi, guys. This is my code for my optimization problem:
Objective=@Case;
p0 =[1,1,1,1,1,1,1];
A = [];
b = [];
Aeq = [];
beq = [];
lb=[1;1;1;1;1;1;1];
ub=[7;7;7;7;7;7;7];
C = fmincon(Objective, p0, A, b, Aeq, beq, lb, ub);
disp(C)
function E=Case(p)
moleWt=[28;56;84;112;140;168;156]; % mole weight C2,C4,…,C12,C11 [g/mol]
Woo_Datas_g = {[0.377984 0.696286 2.9244 4.43634 4.63528 4.83422 4.47613],[0.656499 1.69098 5.5504 11.1605 10.882 9.33024 10.6034],[0.69628 1.53183 4.43634 5.74934 6.78382 4.66446 6.98276],[0.497347 1.17374 2.68568 3.6008 2.9244 3.95889 4.07825],[0.497347 1.01459 1.57162 2.2878 2.88462 2.96419 2.48674]}; %Woo’s data set for C2,C4,..,C12
F_G_out_mmol = [0.354 0.207 0.169 0.0724 0.0179 0.278 0.291]; %Gas outlet for each case[mmol/s]
t_max = 18000; %Reaction duration[s]
F_G_out_mol = zeros(1,7); %Gas outlet for each case at the end of the reaction[mol]
for j=1:7
F_G_out_mol(j) = F_G_out_mmol(j)*t_max*1e-3;
end
C4_mol = zeros(1,7); %C4H8 product(mol)
C6_mol = zeros(1,7); %C6H12 product(mol)
C8_mol = zeros(1,7); %C8H16 product(mol)
C10_mol = zeros(1,7); %C10H24 product(mol)
C12_mol = zeros(1,7); %C12H224 product(mol)
C4_g = cell2mat(Woo_Datas_g(1)); %C4H8 product(mol)
C6_g = cell2mat(Woo_Datas_g(2)); %C6H12 product(mol)
C8_g = cell2mat(Woo_Datas_g(3)); %C8H16 product(mol)
C10_g = cell2mat(Woo_Datas_g(4)); %C10H20 product(mol)
C12_g = cell2mat(Woo_Datas_g(5)); %C12H24 product(mol)
for j=1:7
C4_mol(j) = C4_g(j)./moleWt(2);
C6_mol(j) = C6_g(j)./moleWt(3);
C8_mol(j) = C8_g(j)./moleWt(4);
C10_mol(j) = C10_g(j)./moleWt(5);
C12_mol(j) = C12_g(j)./moleWt(6);
end
a = p(1);
b = p(2);
c = p(3);
d = p(4);
e = p(5);
E = (F_G_out_mol(1)-(C4_mol(a)+C6_mol(b)+C8_mol(c)+C10_mol(d)+C12_mol(e)))^2;
end
As you can see I want E as my objective function. The problem is my parameters for this problem. a,b,c,d,e should be positive integers and they can’t be something like 3.5, 0.5 etc. They can only be 1,2,3,..,7. The problem is I can’t figure out how define this in fmincon(). Any suggestions for solving this issue?? I have tried to use floor() before the parameters but fmincon() gave me a weird answer (1.99 for all the parameters). I also want E to be as minimum as possible. How can I adjust the error in fmincon()??Hi, guys. This is my code for my optimization problem:
Objective=@Case;
p0 =[1,1,1,1,1,1,1];
A = [];
b = [];
Aeq = [];
beq = [];
lb=[1;1;1;1;1;1;1];
ub=[7;7;7;7;7;7;7];
C = fmincon(Objective, p0, A, b, Aeq, beq, lb, ub);
disp(C)
function E=Case(p)
moleWt=[28;56;84;112;140;168;156]; % mole weight C2,C4,…,C12,C11 [g/mol]
Woo_Datas_g = {[0.377984 0.696286 2.9244 4.43634 4.63528 4.83422 4.47613],[0.656499 1.69098 5.5504 11.1605 10.882 9.33024 10.6034],[0.69628 1.53183 4.43634 5.74934 6.78382 4.66446 6.98276],[0.497347 1.17374 2.68568 3.6008 2.9244 3.95889 4.07825],[0.497347 1.01459 1.57162 2.2878 2.88462 2.96419 2.48674]}; %Woo’s data set for C2,C4,..,C12
F_G_out_mmol = [0.354 0.207 0.169 0.0724 0.0179 0.278 0.291]; %Gas outlet for each case[mmol/s]
t_max = 18000; %Reaction duration[s]
F_G_out_mol = zeros(1,7); %Gas outlet for each case at the end of the reaction[mol]
for j=1:7
F_G_out_mol(j) = F_G_out_mmol(j)*t_max*1e-3;
end
C4_mol = zeros(1,7); %C4H8 product(mol)
C6_mol = zeros(1,7); %C6H12 product(mol)
C8_mol = zeros(1,7); %C8H16 product(mol)
C10_mol = zeros(1,7); %C10H24 product(mol)
C12_mol = zeros(1,7); %C12H224 product(mol)
C4_g = cell2mat(Woo_Datas_g(1)); %C4H8 product(mol)
C6_g = cell2mat(Woo_Datas_g(2)); %C6H12 product(mol)
C8_g = cell2mat(Woo_Datas_g(3)); %C8H16 product(mol)
C10_g = cell2mat(Woo_Datas_g(4)); %C10H20 product(mol)
C12_g = cell2mat(Woo_Datas_g(5)); %C12H24 product(mol)
for j=1:7
C4_mol(j) = C4_g(j)./moleWt(2);
C6_mol(j) = C6_g(j)./moleWt(3);
C8_mol(j) = C8_g(j)./moleWt(4);
C10_mol(j) = C10_g(j)./moleWt(5);
C12_mol(j) = C12_g(j)./moleWt(6);
end
a = p(1);
b = p(2);
c = p(3);
d = p(4);
e = p(5);
E = (F_G_out_mol(1)-(C4_mol(a)+C6_mol(b)+C8_mol(c)+C10_mol(d)+C12_mol(e)))^2;
end
As you can see I want E as my objective function. The problem is my parameters for this problem. a,b,c,d,e should be positive integers and they can’t be something like 3.5, 0.5 etc. They can only be 1,2,3,..,7. The problem is I can’t figure out how define this in fmincon(). Any suggestions for solving this issue?? I have tried to use floor() before the parameters but fmincon() gave me a weird answer (1.99 for all the parameters). I also want E to be as minimum as possible. How can I adjust the error in fmincon()?? Hi, guys. This is my code for my optimization problem:
Objective=@Case;
p0 =[1,1,1,1,1,1,1];
A = [];
b = [];
Aeq = [];
beq = [];
lb=[1;1;1;1;1;1;1];
ub=[7;7;7;7;7;7;7];
C = fmincon(Objective, p0, A, b, Aeq, beq, lb, ub);
disp(C)
function E=Case(p)
moleWt=[28;56;84;112;140;168;156]; % mole weight C2,C4,…,C12,C11 [g/mol]
Woo_Datas_g = {[0.377984 0.696286 2.9244 4.43634 4.63528 4.83422 4.47613],[0.656499 1.69098 5.5504 11.1605 10.882 9.33024 10.6034],[0.69628 1.53183 4.43634 5.74934 6.78382 4.66446 6.98276],[0.497347 1.17374 2.68568 3.6008 2.9244 3.95889 4.07825],[0.497347 1.01459 1.57162 2.2878 2.88462 2.96419 2.48674]}; %Woo’s data set for C2,C4,..,C12
F_G_out_mmol = [0.354 0.207 0.169 0.0724 0.0179 0.278 0.291]; %Gas outlet for each case[mmol/s]
t_max = 18000; %Reaction duration[s]
F_G_out_mol = zeros(1,7); %Gas outlet for each case at the end of the reaction[mol]
for j=1:7
F_G_out_mol(j) = F_G_out_mmol(j)*t_max*1e-3;
end
C4_mol = zeros(1,7); %C4H8 product(mol)
C6_mol = zeros(1,7); %C6H12 product(mol)
C8_mol = zeros(1,7); %C8H16 product(mol)
C10_mol = zeros(1,7); %C10H24 product(mol)
C12_mol = zeros(1,7); %C12H224 product(mol)
C4_g = cell2mat(Woo_Datas_g(1)); %C4H8 product(mol)
C6_g = cell2mat(Woo_Datas_g(2)); %C6H12 product(mol)
C8_g = cell2mat(Woo_Datas_g(3)); %C8H16 product(mol)
C10_g = cell2mat(Woo_Datas_g(4)); %C10H20 product(mol)
C12_g = cell2mat(Woo_Datas_g(5)); %C12H24 product(mol)
for j=1:7
C4_mol(j) = C4_g(j)./moleWt(2);
C6_mol(j) = C6_g(j)./moleWt(3);
C8_mol(j) = C8_g(j)./moleWt(4);
C10_mol(j) = C10_g(j)./moleWt(5);
C12_mol(j) = C12_g(j)./moleWt(6);
end
a = p(1);
b = p(2);
c = p(3);
d = p(4);
e = p(5);
E = (F_G_out_mol(1)-(C4_mol(a)+C6_mol(b)+C8_mol(c)+C10_mol(d)+C12_mol(e)))^2;
end
As you can see I want E as my objective function. The problem is my parameters for this problem. a,b,c,d,e should be positive integers and they can’t be something like 3.5, 0.5 etc. They can only be 1,2,3,..,7. The problem is I can’t figure out how define this in fmincon(). Any suggestions for solving this issue?? I have tried to use floor() before the parameters but fmincon() gave me a weird answer (1.99 for all the parameters). I also want E to be as minimum as possible. How can I adjust the error in fmincon()?? optimization MATLAB Answers — New Questions
I’m trying to convert the text into binary and then i want to make the 4 bits chunks.
But the problem is that how to make the total size at the output for example: 001010101010001110101110111010110101.
its mean that i have only 1 row and 36 columns.
but i can’t do it.
please help me out!
clc;
close all;
clear alll;
% I’m trying to convert the Hello World into binary
message = (‘Hello world’);
A = dec2bin(message, 8); % Now to convert the charactors into 8 Bits using ASCI.
[r c]=size(A);
cc=struct([]);
A=convertCharsToStrings(A);
for j=1:1:r;
z=A(j,:);
cc=cat(2,cc,A(j,:));
end
disp(cc);But the problem is that how to make the total size at the output for example: 001010101010001110101110111010110101.
its mean that i have only 1 row and 36 columns.
but i can’t do it.
please help me out!
clc;
close all;
clear alll;
% I’m trying to convert the Hello World into binary
message = (‘Hello world’);
A = dec2bin(message, 8); % Now to convert the charactors into 8 Bits using ASCI.
[r c]=size(A);
cc=struct([]);
A=convertCharsToStrings(A);
for j=1:1:r;
z=A(j,:);
cc=cat(2,cc,A(j,:));
end
disp(cc); But the problem is that how to make the total size at the output for example: 001010101010001110101110111010110101.
its mean that i have only 1 row and 36 columns.
but i can’t do it.
please help me out!
clc;
close all;
clear alll;
% I’m trying to convert the Hello World into binary
message = (‘Hello world’);
A = dec2bin(message, 8); % Now to convert the charactors into 8 Bits using ASCI.
[r c]=size(A);
cc=struct([]);
A=convertCharsToStrings(A);
for j=1:1:r;
z=A(j,:);
cc=cat(2,cc,A(j,:));
end
disp(cc); matlab function, binary MATLAB Answers — New Questions
Code Generation folder for C/C++ code block
Hello,
I am using the C/C++ code block to include some custome C code in my model. I am buiilding the code by using the "Build" button pictured below:
This works fine and produces a C source file.
My issue is when I CodeGen I have to manually include this Custom Code file in the folder each time (it gets deleted otherwise).
I am curious is there a way to control where this C/C++ codeblock builds its file and how I can have that build location to be the same as CodeGeneration ? Right now the C/C++ function always builds to the root directory of my simulink project.Hello,
I am using the C/C++ code block to include some custome C code in my model. I am buiilding the code by using the "Build" button pictured below:
This works fine and produces a C source file.
My issue is when I CodeGen I have to manually include this Custom Code file in the folder each time (it gets deleted otherwise).
I am curious is there a way to control where this C/C++ codeblock builds its file and how I can have that build location to be the same as CodeGeneration ? Right now the C/C++ function always builds to the root directory of my simulink project. Hello,
I am using the C/C++ code block to include some custome C code in my model. I am buiilding the code by using the "Build" button pictured below:
This works fine and produces a C source file.
My issue is when I CodeGen I have to manually include this Custom Code file in the folder each time (it gets deleted otherwise).
I am curious is there a way to control where this C/C++ codeblock builds its file and how I can have that build location to be the same as CodeGeneration ? Right now the C/C++ function always builds to the root directory of my simulink project. c/c++ code block, build folder, code generation MATLAB Answers — New Questions
Sorting of table except first ROW
I have one table
table = uitable(fig, ‘Data’, tableData, ‘ColumnName’, columnNames, ‘ColumnEditable’, true, …
‘Position’, [17, 50, 870, 400], ‘CellSelectionCallback’, @(src, event) tableCellSelectionCallback(event), ‘SelectionType’, ‘row’, ‘RowName’, ”,’RowStriping’,’off’,’ColumnSortable’,true);
this i have "ColumnSortable = true" which provide me a sorting in my table. but i want to execlude first row of table from this sorting can i do that..?
or do we have any call back when sort button is hit on ui…?I have one table
table = uitable(fig, ‘Data’, tableData, ‘ColumnName’, columnNames, ‘ColumnEditable’, true, …
‘Position’, [17, 50, 870, 400], ‘CellSelectionCallback’, @(src, event) tableCellSelectionCallback(event), ‘SelectionType’, ‘row’, ‘RowName’, ”,’RowStriping’,’off’,’ColumnSortable’,true);
this i have "ColumnSortable = true" which provide me a sorting in my table. but i want to execlude first row of table from this sorting can i do that..?
or do we have any call back when sort button is hit on ui…? I have one table
table = uitable(fig, ‘Data’, tableData, ‘ColumnName’, columnNames, ‘ColumnEditable’, true, …
‘Position’, [17, 50, 870, 400], ‘CellSelectionCallback’, @(src, event) tableCellSelectionCallback(event), ‘SelectionType’, ‘row’, ‘RowName’, ”,’RowStriping’,’off’,’ColumnSortable’,true);
this i have "ColumnSortable = true" which provide me a sorting in my table. but i want to execlude first row of table from this sorting can i do that..?
or do we have any call back when sort button is hit on ui…? simulink, matlab, sort MATLAB Answers — New Questions
How to use Taylor Series in stateflow?
I want to use Trigonometric function or Taylor Series in Stateflow, Not Simulink block.
How can I use it like that?I want to use Trigonometric function or Taylor Series in Stateflow, Not Simulink block.
How can I use it like that? I want to use Trigonometric function or Taylor Series in Stateflow, Not Simulink block.
How can I use it like that? simulink, electric_motor_control MATLAB Answers — New Questions
The function’s input parameter must be a vector or matrix, and the function must add 1 to each element of the input parameter.
In matlab i need to do the following operations. The function’s input parameter must be a vector or matrix, and the function must add 1 to each element of the input parameter.In matlab i need to do the following operations. The function’s input parameter must be a vector or matrix, and the function must add 1 to each element of the input parameter. In matlab i need to do the following operations. The function’s input parameter must be a vector or matrix, and the function must add 1 to each element of the input parameter. the function must add 1 to each element of the inp, homework, no attempt MATLAB Answers — New Questions
generate scenario on matlab
Can I make scenario file on matlab?
I’m trying to make vehicles on roadrunner using matlab but I can’t find any way.Can I make scenario file on matlab?
I’m trying to make vehicles on roadrunner using matlab but I can’t find any way. Can I make scenario file on matlab?
I’m trying to make vehicles on roadrunner using matlab but I can’t find any way. roadrunner, scenario MATLAB Answers — New Questions
Can I use matlab to write and execute 8051 assembly language programs?
ORG 0000H
MOV R2,#05H
MOV R0,#30H
MOV R1,#40H
REPEAT: MOV A,@R0
XCH A,@R1
MOV @R0,A
INC R0
INC R1
DJNZ R2,REPEAT
ENDORG 0000H
MOV R2,#05H
MOV R0,#30H
MOV R1,#40H
REPEAT: MOV A,@R0
XCH A,@R1
MOV @R0,A
INC R0
INC R1
DJNZ R2,REPEAT
END ORG 0000H
MOV R2,#05H
MOV R0,#30H
MOV R1,#40H
REPEAT: MOV A,@R0
XCH A,@R1
MOV @R0,A
INC R0
INC R1
DJNZ R2,REPEAT
END 8051 assembl language programs MATLAB Answers — New Questions
How to read multiple grb2 files on a webpage ?
Dear all,
I like to download all the grb2 files from the following website:
https://polar.ncep.noaa.gov/waves/hindcasts/multi_1/200502/gribs
The file link can be identified, for instance, the first one is:
https://polar.ncep.noaa.gov/waves/hindcasts/multi_1/200502/gribs/multi_1.ak_4m.dp.200502.grb2
Is there a way to automatically update the link to download these files?
Thanks for the help.Dear all,
I like to download all the grb2 files from the following website:
https://polar.ncep.noaa.gov/waves/hindcasts/multi_1/200502/gribs
The file link can be identified, for instance, the first one is:
https://polar.ncep.noaa.gov/waves/hindcasts/multi_1/200502/gribs/multi_1.ak_4m.dp.200502.grb2
Is there a way to automatically update the link to download these files?
Thanks for the help. Dear all,
I like to download all the grb2 files from the following website:
https://polar.ncep.noaa.gov/waves/hindcasts/multi_1/200502/gribs
The file link can be identified, for instance, the first one is:
https://polar.ncep.noaa.gov/waves/hindcasts/multi_1/200502/gribs/multi_1.ak_4m.dp.200502.grb2
Is there a way to automatically update the link to download these files?
Thanks for the help. webread, grb2 data, batch operation MATLAB Answers — New Questions
I need to find the answer for the following error and code
sum1 = zeros(172,1);
sum2 = 0;
for i = 1:length(data2) % Iterate up to the length of H_BM or g_mean
sum1(i) = P1(i)*(g_p(i)+((g_mean(i).*H_BM(i))*(10)^(-5)));
sum2 = sum2 + P1(i);
%fprintf(‘Iteration %d: sum1 = %.6fn’, i, sum1(i)); % Print iteration output of sum1
end
xx = sum1;
total = sum(xx)
ssum = sum1.*H_BM;
std_ssum = std(ssum,1);
std_ssum
there is a error when taking the total. "Array indices must be positive integers or logical values." please help me to solve this problem.sum1 = zeros(172,1);
sum2 = 0;
for i = 1:length(data2) % Iterate up to the length of H_BM or g_mean
sum1(i) = P1(i)*(g_p(i)+((g_mean(i).*H_BM(i))*(10)^(-5)));
sum2 = sum2 + P1(i);
%fprintf(‘Iteration %d: sum1 = %.6fn’, i, sum1(i)); % Print iteration output of sum1
end
xx = sum1;
total = sum(xx)
ssum = sum1.*H_BM;
std_ssum = std(ssum,1);
std_ssum
there is a error when taking the total. "Array indices must be positive integers or logical values." please help me to solve this problem. sum1 = zeros(172,1);
sum2 = 0;
for i = 1:length(data2) % Iterate up to the length of H_BM or g_mean
sum1(i) = P1(i)*(g_p(i)+((g_mean(i).*H_BM(i))*(10)^(-5)));
sum2 = sum2 + P1(i);
%fprintf(‘Iteration %d: sum1 = %.6fn’, i, sum1(i)); % Print iteration output of sum1
end
xx = sum1;
total = sum(xx)
ssum = sum1.*H_BM;
std_ssum = std(ssum,1);
std_ssum
there is a error when taking the total. "Array indices must be positive integers or logical values." please help me to solve this problem. array indices logical values. MATLAB Answers — New Questions
I need help fixing backtracking function on code for puzzle solver.
Can’t find what I’m missing in the code for this backtracking function to run correctly.
% Define the missing functions
function [imax, jmax, MaxScore] = findNextCell(P, HashRow, HashCol, HashBlock)
% Find the next cell with the least number of possible values
imax = 0; jmax = 0; MaxScore = -1;
for i = 1:16
for j = 1:16
if P(i,j) == -1
score = sum(HashRow(i,:)) + sum(HashCol(j,:)) + sum(sum(HashBlock(ceil(i/4),ceil(j/4),:)));
if score > MaxScore
MaxScore = score;
imax = i;
jmax = j;
else
end
end
end
end
endCan’t find what I’m missing in the code for this backtracking function to run correctly.
% Define the missing functions
function [imax, jmax, MaxScore] = findNextCell(P, HashRow, HashCol, HashBlock)
% Find the next cell with the least number of possible values
imax = 0; jmax = 0; MaxScore = -1;
for i = 1:16
for j = 1:16
if P(i,j) == -1
score = sum(HashRow(i,:)) + sum(HashCol(j,:)) + sum(sum(HashBlock(ceil(i/4),ceil(j/4),:)));
if score > MaxScore
MaxScore = score;
imax = i;
jmax = j;
else
end
end
end
end
end Can’t find what I’m missing in the code for this backtracking function to run correctly.
% Define the missing functions
function [imax, jmax, MaxScore] = findNextCell(P, HashRow, HashCol, HashBlock)
% Find the next cell with the least number of possible values
imax = 0; jmax = 0; MaxScore = -1;
for i = 1:16
for j = 1:16
if P(i,j) == -1
score = sum(HashRow(i,:)) + sum(HashCol(j,:)) + sum(sum(HashBlock(ceil(i/4),ceil(j/4),:)));
if score > MaxScore
MaxScore = score;
imax = i;
jmax = j;
else
end
end
end
end
end backtrack, puzzle MATLAB Answers — New Questions
How to interpret the amplitude of impulse() results
Hi,
For the given transfer function, the frequency response and step response make sense to me.
But why the amplitude of impulse response is so large?
If I want to use the impulse response to conv any input signals to the system, the amplitude of output will be wrong.
SInce the Delta function doesn’t exist in reality, how does Matlab impulse() function compute it? Do I need to scale it?
Thanks in advance!
/HG
% RC low pass filter
fco = 0.7e9;
wco = fco * 2 * pi;
tau = 1 / wco;
num = [1];
den = [1/wco, 1];
% check tf model
figure
sys = tf(num, den)
bode(sys)
figure
step(sys)
figure
impulse(sys)Hi,
For the given transfer function, the frequency response and step response make sense to me.
But why the amplitude of impulse response is so large?
If I want to use the impulse response to conv any input signals to the system, the amplitude of output will be wrong.
SInce the Delta function doesn’t exist in reality, how does Matlab impulse() function compute it? Do I need to scale it?
Thanks in advance!
/HG
% RC low pass filter
fco = 0.7e9;
wco = fco * 2 * pi;
tau = 1 / wco;
num = [1];
den = [1/wco, 1];
% check tf model
figure
sys = tf(num, den)
bode(sys)
figure
step(sys)
figure
impulse(sys) Hi,
For the given transfer function, the frequency response and step response make sense to me.
But why the amplitude of impulse response is so large?
If I want to use the impulse response to conv any input signals to the system, the amplitude of output will be wrong.
SInce the Delta function doesn’t exist in reality, how does Matlab impulse() function compute it? Do I need to scale it?
Thanks in advance!
/HG
% RC low pass filter
fco = 0.7e9;
wco = fco * 2 * pi;
tau = 1 / wco;
num = [1];
den = [1/wco, 1];
% check tf model
figure
sys = tf(num, den)
bode(sys)
figure
step(sys)
figure
impulse(sys) impulse response MATLAB Answers — New Questions
Received Output High SNR Error
How to correct received output high SNR error?
clc;
clear all;
% Load the ‘lenna’ image
lenna = imread(‘lenna.png’);
% Convert the image to grayscale
lenna_gray = rgb2gray(lenna);
% Convert pixel values to bits
lenna_bits = reshape(de2bi(lenna_gray), [], 1);
% Define Eb/No values for low and high SNR
Eb_No_low = 0;
Eb_No_high = 4;
% Calculate SNR values for low and high SNR
SNR_low = 10^(Eb_No_low/10);
SNR_high = 10^(Eb_No_high/10);
% Transmit and receive at low SNR
received_low = awgn(double(lenna_bits), SNR_low, ‘measured’);
% Demodulate received bits at low SNR
decoded_low = received_low < 0;
% Reshape decoded bits to original image size at low SNR
szin = size(lenna_gray,1:2);
decoded_image_low = reshape(decoded_low, prod(szin), []); % reshape into binary words
decoded_image_low = uint8(bi2de(decoded_image_low)); % convert to uint8 vector
decoded_image_low = reshape(decoded_image_low, szin); % devectorize
% Plot original and received image at low SNR
figure;
subplot(1, 2, 1);
imshow(lenna_gray);
title(‘Original Image’);
subplot(1, 2, 2);
imshow(decoded_image_low);
title(‘Received Image (0 dB SNR)’);
% Define the parity matrix
parityMatrix = [1 1 0 1 0 0 0;
1 0 1 0 1 0 0;
0 1 1 0 0 1 0;
1 1 1 0 0 0 1];
% Concatenate the identity matrix and the transposed parity matrix to form the generator matrix
generatorMatrix = [eye(4), parityMatrix]; % Transpose parityMatrix to make its dimensions compatible
% Transmit and receive at high SNR
received_high = awgn(double(lenna_bits), SNR_high, ‘measured’);
% Demodulate received bits at high SNR
decoded_high = received_high < 0;
% Reshape decoded bits to original image size at high SNR
decoded_image_high = reshape(decoded_high, size(lenna_gray, 1), []);
% Plot original and received image at high SNR
figure;
subplot(1, 2, 1);
imshow(lenna_gray);
title(‘Original Image’);
subplot(1, 2, 2);
imshow(decoded_image_high);
title(‘Received Image (4 dB SNR)’);How to correct received output high SNR error?
clc;
clear all;
% Load the ‘lenna’ image
lenna = imread(‘lenna.png’);
% Convert the image to grayscale
lenna_gray = rgb2gray(lenna);
% Convert pixel values to bits
lenna_bits = reshape(de2bi(lenna_gray), [], 1);
% Define Eb/No values for low and high SNR
Eb_No_low = 0;
Eb_No_high = 4;
% Calculate SNR values for low and high SNR
SNR_low = 10^(Eb_No_low/10);
SNR_high = 10^(Eb_No_high/10);
% Transmit and receive at low SNR
received_low = awgn(double(lenna_bits), SNR_low, ‘measured’);
% Demodulate received bits at low SNR
decoded_low = received_low < 0;
% Reshape decoded bits to original image size at low SNR
szin = size(lenna_gray,1:2);
decoded_image_low = reshape(decoded_low, prod(szin), []); % reshape into binary words
decoded_image_low = uint8(bi2de(decoded_image_low)); % convert to uint8 vector
decoded_image_low = reshape(decoded_image_low, szin); % devectorize
% Plot original and received image at low SNR
figure;
subplot(1, 2, 1);
imshow(lenna_gray);
title(‘Original Image’);
subplot(1, 2, 2);
imshow(decoded_image_low);
title(‘Received Image (0 dB SNR)’);
% Define the parity matrix
parityMatrix = [1 1 0 1 0 0 0;
1 0 1 0 1 0 0;
0 1 1 0 0 1 0;
1 1 1 0 0 0 1];
% Concatenate the identity matrix and the transposed parity matrix to form the generator matrix
generatorMatrix = [eye(4), parityMatrix]; % Transpose parityMatrix to make its dimensions compatible
% Transmit and receive at high SNR
received_high = awgn(double(lenna_bits), SNR_high, ‘measured’);
% Demodulate received bits at high SNR
decoded_high = received_high < 0;
% Reshape decoded bits to original image size at high SNR
decoded_image_high = reshape(decoded_high, size(lenna_gray, 1), []);
% Plot original and received image at high SNR
figure;
subplot(1, 2, 1);
imshow(lenna_gray);
title(‘Original Image’);
subplot(1, 2, 2);
imshow(decoded_image_high);
title(‘Received Image (4 dB SNR)’); How to correct received output high SNR error?
clc;
clear all;
% Load the ‘lenna’ image
lenna = imread(‘lenna.png’);
% Convert the image to grayscale
lenna_gray = rgb2gray(lenna);
% Convert pixel values to bits
lenna_bits = reshape(de2bi(lenna_gray), [], 1);
% Define Eb/No values for low and high SNR
Eb_No_low = 0;
Eb_No_high = 4;
% Calculate SNR values for low and high SNR
SNR_low = 10^(Eb_No_low/10);
SNR_high = 10^(Eb_No_high/10);
% Transmit and receive at low SNR
received_low = awgn(double(lenna_bits), SNR_low, ‘measured’);
% Demodulate received bits at low SNR
decoded_low = received_low < 0;
% Reshape decoded bits to original image size at low SNR
szin = size(lenna_gray,1:2);
decoded_image_low = reshape(decoded_low, prod(szin), []); % reshape into binary words
decoded_image_low = uint8(bi2de(decoded_image_low)); % convert to uint8 vector
decoded_image_low = reshape(decoded_image_low, szin); % devectorize
% Plot original and received image at low SNR
figure;
subplot(1, 2, 1);
imshow(lenna_gray);
title(‘Original Image’);
subplot(1, 2, 2);
imshow(decoded_image_low);
title(‘Received Image (0 dB SNR)’);
% Define the parity matrix
parityMatrix = [1 1 0 1 0 0 0;
1 0 1 0 1 0 0;
0 1 1 0 0 1 0;
1 1 1 0 0 0 1];
% Concatenate the identity matrix and the transposed parity matrix to form the generator matrix
generatorMatrix = [eye(4), parityMatrix]; % Transpose parityMatrix to make its dimensions compatible
% Transmit and receive at high SNR
received_high = awgn(double(lenna_bits), SNR_high, ‘measured’);
% Demodulate received bits at high SNR
decoded_high = received_high < 0;
% Reshape decoded bits to original image size at high SNR
decoded_image_high = reshape(decoded_high, size(lenna_gray, 1), []);
% Plot original and received image at high SNR
figure;
subplot(1, 2, 1);
imshow(lenna_gray);
title(‘Original Image’);
subplot(1, 2, 2);
imshow(decoded_image_high);
title(‘Received Image (4 dB SNR)’); high snr error MATLAB Answers — New Questions
Find data from txt file
Hi all,
I try to find a data from txt file. In a row (i don’t known which row), there is an information like "Dt: 0.0001". I want to find this row and store 0.0001 as a variable. How can i do that?
Thanks for helpHi all,
I try to find a data from txt file. In a row (i don’t known which row), there is an information like "Dt: 0.0001". I want to find this row and store 0.0001 as a variable. How can i do that?
Thanks for help Hi all,
I try to find a data from txt file. In a row (i don’t known which row), there is an information like "Dt: 0.0001". I want to find this row and store 0.0001 as a variable. How can i do that?
Thanks for help finder, txt, data MATLAB Answers — New Questions
Display Text Without Formatting
The following string displays in the command window formatted as a hyperlink. How do I display the entire contents of str without formatting?
>> str = ‘<a href="test">TEST</a>’
str =
TESTThe following string displays in the command window formatted as a hyperlink. How do I display the entire contents of str without formatting?
>> str = ‘<a href="test">TEST</a>’
str =
TEST The following string displays in the command window formatted as a hyperlink. How do I display the entire contents of str without formatting?
>> str = ‘<a href="test">TEST</a>’
str =
TEST display, hyperlink MATLAB Answers — New Questions
How can I find the troughs of something without using the function findpeaks?
%This function is meant to help me find the troughs of the flow plot but I keep getting values that almost work but don’t work, I was told by a classmate that to find the troughs I need to find the beaks then work backwards
function [troughs] = findTroughs(flowData)
flow = flowData(:,2);
t = flowData(:,1);
troughs = [];
for i = 3:length(flow)-2
if flow(i) < flow(i-1) && flow(i) < flow(i-2) && flow(i) < flow(i+1) && flow(i) < flow(i+2)
isAbsolute = true;
for j = (i-10):(i+10)
if j>=1 && j<=length(flow) && flow(i)>flow(j)
isAbsolute = false;
break
end
end
if isAbsolute && ~any(troughs == i) % Check if trough index already exists
troughs = [troughs, i];
end
end
end
end%This function is meant to help me find the troughs of the flow plot but I keep getting values that almost work but don’t work, I was told by a classmate that to find the troughs I need to find the beaks then work backwards
function [troughs] = findTroughs(flowData)
flow = flowData(:,2);
t = flowData(:,1);
troughs = [];
for i = 3:length(flow)-2
if flow(i) < flow(i-1) && flow(i) < flow(i-2) && flow(i) < flow(i+1) && flow(i) < flow(i+2)
isAbsolute = true;
for j = (i-10):(i+10)
if j>=1 && j<=length(flow) && flow(i)>flow(j)
isAbsolute = false;
break
end
end
if isAbsolute && ~any(troughs == i) % Check if trough index already exists
troughs = [troughs, i];
end
end
end
end %This function is meant to help me find the troughs of the flow plot but I keep getting values that almost work but don’t work, I was told by a classmate that to find the troughs I need to find the beaks then work backwards
function [troughs] = findTroughs(flowData)
flow = flowData(:,2);
t = flowData(:,1);
troughs = [];
for i = 3:length(flow)-2
if flow(i) < flow(i-1) && flow(i) < flow(i-2) && flow(i) < flow(i+1) && flow(i) < flow(i+2)
isAbsolute = true;
for j = (i-10):(i+10)
if j>=1 && j<=length(flow) && flow(i)>flow(j)
isAbsolute = false;
break
end
end
if isAbsolute && ~any(troughs == i) % Check if trough index already exists
troughs = [troughs, i];
end
end
end
end plotting, subplot MATLAB Answers — New Questions
Make Parametric Curves Plot Smoother
I have an application where I am hoping to plot a region inside a parametric curve, and I need the plot to be fairly close up to the curve, however this seems to have a staircasing effect on the curve. I have plotted an example below which shows the staircasing, (I have increased the line width to help the problem be visible). Is there a way to smooth this out? Refining the discretization doesn’t seem to help. I understand that the curve is discrete and won’t look perfect, but any suggestions are welcome!
t = linspace(0,2*pi,100);
x =cos(t) + 0.65 * cos(2 * t) -0.65; y = 1.5 * sin(t);
plot(x,y,’Linewidth’,1.5)I have an application where I am hoping to plot a region inside a parametric curve, and I need the plot to be fairly close up to the curve, however this seems to have a staircasing effect on the curve. I have plotted an example below which shows the staircasing, (I have increased the line width to help the problem be visible). Is there a way to smooth this out? Refining the discretization doesn’t seem to help. I understand that the curve is discrete and won’t look perfect, but any suggestions are welcome!
t = linspace(0,2*pi,100);
x =cos(t) + 0.65 * cos(2 * t) -0.65; y = 1.5 * sin(t);
plot(x,y,’Linewidth’,1.5) I have an application where I am hoping to plot a region inside a parametric curve, and I need the plot to be fairly close up to the curve, however this seems to have a staircasing effect on the curve. I have plotted an example below which shows the staircasing, (I have increased the line width to help the problem be visible). Is there a way to smooth this out? Refining the discretization doesn’t seem to help. I understand that the curve is discrete and won’t look perfect, but any suggestions are welcome!
t = linspace(0,2*pi,100);
x =cos(t) + 0.65 * cos(2 * t) -0.65; y = 1.5 * sin(t);
plot(x,y,’Linewidth’,1.5) plotting, parametric curve MATLAB Answers — New Questions