Tag Archives: matlab
How to create a bucket in a bucket bucket using MATLAB R213nb
I want to create bucket in bucket using MATLAB R2013bI want to create bucket in bucket using MATLAB R2013b I want to create bucket in bucket using MATLAB R2013b bucketing MATLAB Answers — New Questions
How to define a path of vehicle
I would like to find an approach to define a path of vehicle in path-length coordinate.
As input I have an array of Cartesian coordinates (X, Y). I need to convert it to some function (object) which allow me to get a curvature of path, X, Y as functions of path length.
Also there is a issue that I have a closed path like the following:
<</matlabcentral/answers/uploaded_files/54861/closed_lap.png>>
What can I use for such task?I would like to find an approach to define a path of vehicle in path-length coordinate.
As input I have an array of Cartesian coordinates (X, Y). I need to convert it to some function (object) which allow me to get a curvature of path, X, Y as functions of path length.
Also there is a issue that I have a closed path like the following:
<</matlabcentral/answers/uploaded_files/54861/closed_lap.png>>
What can I use for such task? I would like to find an approach to define a path of vehicle in path-length coordinate.
As input I have an array of Cartesian coordinates (X, Y). I need to convert it to some function (object) which allow me to get a curvature of path, X, Y as functions of path length.
Also there is a issue that I have a closed path like the following:
<</matlabcentral/answers/uploaded_files/54861/closed_lap.png>>
What can I use for such task? spline, path MATLAB Answers — New Questions
Is it possible to access the blocks inside the model under test from the test harness in custom criteria script of simulink test?
I would like to verify the datatype of inports and outports of a model in simulink test. So I created a test harness for it and when I try to access the inports inside the model under test in test harness from the custom cirteria script of simulink test, it doesnt work.
function ioAnalysisFunc(test)
res = get_param(strcat(test.sltest_bdroot, ‘/Model1/Inport1’), ‘OutDataTypeStr’); % Here test.sltest_bdroot is the test harness ‘Model1_Harness’
assignin(‘base’, ‘ress_out’, res{1});
end
The error thrown is,
——————————————————————–
Error occurred in custom criteria and custom criteria assessment did not run to completion.
——— Error ID: ———
Simulink:Commands:InvSimulinkObjectName
————– Error Details: ————–
Invalid Simulink object name: ‘Model1_Harness/Model1/Inport1’.
——————————————————————–I would like to verify the datatype of inports and outports of a model in simulink test. So I created a test harness for it and when I try to access the inports inside the model under test in test harness from the custom cirteria script of simulink test, it doesnt work.
function ioAnalysisFunc(test)
res = get_param(strcat(test.sltest_bdroot, ‘/Model1/Inport1’), ‘OutDataTypeStr’); % Here test.sltest_bdroot is the test harness ‘Model1_Harness’
assignin(‘base’, ‘ress_out’, res{1});
end
The error thrown is,
——————————————————————–
Error occurred in custom criteria and custom criteria assessment did not run to completion.
——— Error ID: ———
Simulink:Commands:InvSimulinkObjectName
————– Error Details: ————–
Invalid Simulink object name: ‘Model1_Harness/Model1/Inport1’.
——————————————————————– I would like to verify the datatype of inports and outports of a model in simulink test. So I created a test harness for it and when I try to access the inports inside the model under test in test harness from the custom cirteria script of simulink test, it doesnt work.
function ioAnalysisFunc(test)
res = get_param(strcat(test.sltest_bdroot, ‘/Model1/Inport1’), ‘OutDataTypeStr’); % Here test.sltest_bdroot is the test harness ‘Model1_Harness’
assignin(‘base’, ‘ress_out’, res{1});
end
The error thrown is,
——————————————————————–
Error occurred in custom criteria and custom criteria assessment did not run to completion.
——— Error ID: ———
Simulink:Commands:InvSimulinkObjectName
————– Error Details: ————–
Invalid Simulink object name: ‘Model1_Harness/Model1/Inport1’.
——————————————————————– simulink test, custom criteria script, get_param MATLAB Answers — New Questions
Galerkin method fix the linear two-point BVP
I am a newcomer to matlab,I want to use the Galerkin method with the hat function as the set of basis functions to calculate the solution to the linear two-point BVP :
The hat knots are evenly distributed with the interval h = 1/20 and 1/40.
Compare the results to those of the exact solution, , to evaluate the order of accuracy using
the absolute errors for the two knot intervals.
Hope someone can teach or guide me how to do it .I am a newcomer to matlab,I want to use the Galerkin method with the hat function as the set of basis functions to calculate the solution to the linear two-point BVP :
The hat knots are evenly distributed with the interval h = 1/20 and 1/40.
Compare the results to those of the exact solution, , to evaluate the order of accuracy using
the absolute errors for the two knot intervals.
Hope someone can teach or guide me how to do it . I am a newcomer to matlab,I want to use the Galerkin method with the hat function as the set of basis functions to calculate the solution to the linear two-point BVP :
The hat knots are evenly distributed with the interval h = 1/20 and 1/40.
Compare the results to those of the exact solution, , to evaluate the order of accuracy using
the absolute errors for the two knot intervals.
Hope someone can teach or guide me how to do it . galerkin, hat function MATLAB Answers — New Questions
how to write a program combininb name and age?
In my HB I got an assigment on writing a program that asks for the name and age of a person, then runs the sentence Dear__your age is___, the blank spaces containing the input
I thought about using a switch, the cases being the name inputs, is that something I can do or is there an easier way?In my HB I got an assigment on writing a program that asks for the name and age of a person, then runs the sentence Dear__your age is___, the blank spaces containing the input
I thought about using a switch, the cases being the name inputs, is that something I can do or is there an easier way? In my HB I got an assigment on writing a program that asks for the name and age of a person, then runs the sentence Dear__your age is___, the blank spaces containing the input
I thought about using a switch, the cases being the name inputs, is that something I can do or is there an easier way? homework, help MATLAB Answers — New Questions
Combining two matrices into one
Hi all,
I have a question regarding matrix manipulation in MATLAB.
My scenario is as follows:
I have a set of GPS coordinates, which I have converted into relative meters using an algorithm. These coordinates correspond to locations on a farm which I have gathered data for using a video camera, and roughly correspond to a standard "go up one row, go down the next" path.
For each coordinate, I also have an image at that coordinate, which I am using to identify the location of weeds.
From the GPS coordinates, which are simple X-Y points, I can generate a matrix. The matrix would likely be a roughly 2000×2000 size matrix, where a cell would have a value of 1 if there was a GPS point identifying that the tractor had been on that spot.
The images are 800x600x3 color images.
What I want to be able to do, is take the images, and, using the matrix I made from the GPS coordinates, somehow combine all images together into one large image.
If the images were distinct, then this would not be as big of an issue, as I could generate an 800x600x3 matrix at each cell of the 2000×2000 matrix. This would be a rather large matrix, however, it would accomplish the task.
However, the GPS coordinates are such that an image might overlap to a certain extent with the images adjacent to it.
Can anyone suggest any ways I can accomplish what I am trying to do? The end result simply needs to be a large image I can look at, which will show me the entirety of my farm land, using the images which I have taken.Hi all,
I have a question regarding matrix manipulation in MATLAB.
My scenario is as follows:
I have a set of GPS coordinates, which I have converted into relative meters using an algorithm. These coordinates correspond to locations on a farm which I have gathered data for using a video camera, and roughly correspond to a standard "go up one row, go down the next" path.
For each coordinate, I also have an image at that coordinate, which I am using to identify the location of weeds.
From the GPS coordinates, which are simple X-Y points, I can generate a matrix. The matrix would likely be a roughly 2000×2000 size matrix, where a cell would have a value of 1 if there was a GPS point identifying that the tractor had been on that spot.
The images are 800x600x3 color images.
What I want to be able to do, is take the images, and, using the matrix I made from the GPS coordinates, somehow combine all images together into one large image.
If the images were distinct, then this would not be as big of an issue, as I could generate an 800x600x3 matrix at each cell of the 2000×2000 matrix. This would be a rather large matrix, however, it would accomplish the task.
However, the GPS coordinates are such that an image might overlap to a certain extent with the images adjacent to it.
Can anyone suggest any ways I can accomplish what I am trying to do? The end result simply needs to be a large image I can look at, which will show me the entirety of my farm land, using the images which I have taken. Hi all,
I have a question regarding matrix manipulation in MATLAB.
My scenario is as follows:
I have a set of GPS coordinates, which I have converted into relative meters using an algorithm. These coordinates correspond to locations on a farm which I have gathered data for using a video camera, and roughly correspond to a standard "go up one row, go down the next" path.
For each coordinate, I also have an image at that coordinate, which I am using to identify the location of weeds.
From the GPS coordinates, which are simple X-Y points, I can generate a matrix. The matrix would likely be a roughly 2000×2000 size matrix, where a cell would have a value of 1 if there was a GPS point identifying that the tractor had been on that spot.
The images are 800x600x3 color images.
What I want to be able to do, is take the images, and, using the matrix I made from the GPS coordinates, somehow combine all images together into one large image.
If the images were distinct, then this would not be as big of an issue, as I could generate an 800x600x3 matrix at each cell of the 2000×2000 matrix. This would be a rather large matrix, however, it would accomplish the task.
However, the GPS coordinates are such that an image might overlap to a certain extent with the images adjacent to it.
Can anyone suggest any ways I can accomplish what I am trying to do? The end result simply needs to be a large image I can look at, which will show me the entirety of my farm land, using the images which I have taken. matrix manipulation, image processing MATLAB Answers — New Questions
How to overwrite my data everytime I run my code?
I’m currently writing a program and everytime I run it, it just adds the data to the excel vs deleting the contents of the excel and replacing it with new data. I’m using the writetable function which I thought would automatically clear the excel before filling it with new data. Any ideas?I’m currently writing a program and everytime I run it, it just adds the data to the excel vs deleting the contents of the excel and replacing it with new data. I’m using the writetable function which I thought would automatically clear the excel before filling it with new data. Any ideas? I’m currently writing a program and everytime I run it, it just adds the data to the excel vs deleting the contents of the excel and replacing it with new data. I’m using the writetable function which I thought would automatically clear the excel before filling it with new data. Any ideas? importing excel data MATLAB Answers — New Questions
May I ask how to use MATLAB code to build an ECA module?
May I ask how to use MATLAB code to build an ECA module? The ECA module can refer to this paper: ECA Net: Efficient Channel Attention for Deep Convolutional Neural Networks.
Paper address: https://arxiv.org/abs/1910.03151May I ask how to use MATLAB code to build an ECA module? The ECA module can refer to this paper: ECA Net: Efficient Channel Attention for Deep Convolutional Neural Networks.
Paper address: https://arxiv.org/abs/1910.03151 May I ask how to use MATLAB code to build an ECA module? The ECA module can refer to this paper: ECA Net: Efficient Channel Attention for Deep Convolutional Neural Networks.
Paper address: https://arxiv.org/abs/1910.03151 eca-net, attention mechanism MATLAB Answers — New Questions
Convert pulse to digital
Dear Sir/Madam,
If i represent a pulse with y-axis as time and x-axis as frequency is it possible to convert that pulse into a digital representation having a period that changes with increase in frequency. The figure shows a pulse that starts at 10KHz rises to 10.1KHz then falls back to 10KHz. The sample time for discussion has been set to 1ms.
<</matlabcentral/answers/uploaded_files/117334/pulse.PNG>>
Regards JoeDear Sir/Madam,
If i represent a pulse with y-axis as time and x-axis as frequency is it possible to convert that pulse into a digital representation having a period that changes with increase in frequency. The figure shows a pulse that starts at 10KHz rises to 10.1KHz then falls back to 10KHz. The sample time for discussion has been set to 1ms.
<</matlabcentral/answers/uploaded_files/117334/pulse.PNG>>
Regards Joe Dear Sir/Madam,
If i represent a pulse with y-axis as time and x-axis as frequency is it possible to convert that pulse into a digital representation having a period that changes with increase in frequency. The figure shows a pulse that starts at 10KHz rises to 10.1KHz then falls back to 10KHz. The sample time for discussion has been set to 1ms.
<</matlabcentral/answers/uploaded_files/117334/pulse.PNG>>
Regards Joe pulse, frequency, digital, time MATLAB Answers — New Questions
Problem with finding the global minimum with fmincon
I am currently trying to find the global minimum for a strain-energy-function ("Holzapfel-Model") and I am running into multiple problems:
The SEF has the form
With
We can calculate , where
We want to determine the minimum of the least-square function
My solution was to put all these equations into one long one:
fun = @(x) sum((sigma_11 – (lambda_1.^2 – lambda_2.^2 .* lambda_1.^2).*x(1) + 2 .*lambda_1.^2 .*cos(x(4))^2 .* (2.*x(2).*((lambda_1.^2 .* cos(x(4))^2 + lambda_2.^2 .* sin(x(4))^2) – 1) .* exp(x(2).*((lambda_1.^2 .* cos(x(4))^2 + lambda_2.^2 .* sin(x(4))^2)-1).^2))).^2 + (sigma_22 – (lambda_2.^2 – lambda_2.^2 .* lambda_1.^2).*x(1) + 2 .*lambda_2.^2 .*sin(x(4))^2 .* (2.*x(2).*((lambda_1.^2 .* cos(x(4))^2 + lambda_2.^2 .* sin(x(4))^2) – 1) .* exp(x(2).*((lambda_1.^2 .* cos(x(4))^2 + lambda_2.^2 .* sin(x(4))^2)-1).^2))).^2)
and then use the following parameters
x0 = [15,500,12,0.75*pi];
A = [];
b = [];
Aeq = [];
beq = [];
lb = [0,0,0,0];
ub = [inf, inf, inf, pi];
chi = fmincon(fun, x0,A,b,Aeq,beq,lb,ub,nonlcon)
function [c,ceq] = nonlcon(x,lambda_1,lambda_2)
c =1-(lambda_1.^2 .* cos(x(4)).^2 + lambda_2.^2 * sin(x(4)).^2) ;
ceq = [];
end
With these parameters, I can somewhat get close to my data points.
Now my questions:
I don’t think I understood c,ceq correctly. I used c to account for the constraint on I4, but I’m not sure if this was the right way to do it.
With the initial guess for x0, I can get close but it never seems to approach my curve nearly enough. How do I know if I have a good starting guess, and is fmincon even the right approach for this problem.
I have multiple data sets, for different stretch ratios (lambda_1:lambda_2: 1-1, 1-0.75, 0.75-1, 1-0.5,0.5-1) and since they are the same sample, I would like to use those datas to get one set of parameters for all of them. I tried to put all my data into a single vector, (1:30 would be the first data set, 31:^60 the second,…). This does not seem to work well. Should I find the solution for just one curve and than try to average over the parameters? As you guys can see, I am doing this parameter evaluation thing the first time ever and I would greatly appreciate help.I am currently trying to find the global minimum for a strain-energy-function ("Holzapfel-Model") and I am running into multiple problems:
The SEF has the form
With
We can calculate , where
We want to determine the minimum of the least-square function
My solution was to put all these equations into one long one:
fun = @(x) sum((sigma_11 – (lambda_1.^2 – lambda_2.^2 .* lambda_1.^2).*x(1) + 2 .*lambda_1.^2 .*cos(x(4))^2 .* (2.*x(2).*((lambda_1.^2 .* cos(x(4))^2 + lambda_2.^2 .* sin(x(4))^2) – 1) .* exp(x(2).*((lambda_1.^2 .* cos(x(4))^2 + lambda_2.^2 .* sin(x(4))^2)-1).^2))).^2 + (sigma_22 – (lambda_2.^2 – lambda_2.^2 .* lambda_1.^2).*x(1) + 2 .*lambda_2.^2 .*sin(x(4))^2 .* (2.*x(2).*((lambda_1.^2 .* cos(x(4))^2 + lambda_2.^2 .* sin(x(4))^2) – 1) .* exp(x(2).*((lambda_1.^2 .* cos(x(4))^2 + lambda_2.^2 .* sin(x(4))^2)-1).^2))).^2)
and then use the following parameters
x0 = [15,500,12,0.75*pi];
A = [];
b = [];
Aeq = [];
beq = [];
lb = [0,0,0,0];
ub = [inf, inf, inf, pi];
chi = fmincon(fun, x0,A,b,Aeq,beq,lb,ub,nonlcon)
function [c,ceq] = nonlcon(x,lambda_1,lambda_2)
c =1-(lambda_1.^2 .* cos(x(4)).^2 + lambda_2.^2 * sin(x(4)).^2) ;
ceq = [];
end
With these parameters, I can somewhat get close to my data points.
Now my questions:
I don’t think I understood c,ceq correctly. I used c to account for the constraint on I4, but I’m not sure if this was the right way to do it.
With the initial guess for x0, I can get close but it never seems to approach my curve nearly enough. How do I know if I have a good starting guess, and is fmincon even the right approach for this problem.
I have multiple data sets, for different stretch ratios (lambda_1:lambda_2: 1-1, 1-0.75, 0.75-1, 1-0.5,0.5-1) and since they are the same sample, I would like to use those datas to get one set of parameters for all of them. I tried to put all my data into a single vector, (1:30 would be the first data set, 31:^60 the second,…). This does not seem to work well. Should I find the solution for just one curve and than try to average over the parameters? As you guys can see, I am doing this parameter evaluation thing the first time ever and I would greatly appreciate help. I am currently trying to find the global minimum for a strain-energy-function ("Holzapfel-Model") and I am running into multiple problems:
The SEF has the form
With
We can calculate , where
We want to determine the minimum of the least-square function
My solution was to put all these equations into one long one:
fun = @(x) sum((sigma_11 – (lambda_1.^2 – lambda_2.^2 .* lambda_1.^2).*x(1) + 2 .*lambda_1.^2 .*cos(x(4))^2 .* (2.*x(2).*((lambda_1.^2 .* cos(x(4))^2 + lambda_2.^2 .* sin(x(4))^2) – 1) .* exp(x(2).*((lambda_1.^2 .* cos(x(4))^2 + lambda_2.^2 .* sin(x(4))^2)-1).^2))).^2 + (sigma_22 – (lambda_2.^2 – lambda_2.^2 .* lambda_1.^2).*x(1) + 2 .*lambda_2.^2 .*sin(x(4))^2 .* (2.*x(2).*((lambda_1.^2 .* cos(x(4))^2 + lambda_2.^2 .* sin(x(4))^2) – 1) .* exp(x(2).*((lambda_1.^2 .* cos(x(4))^2 + lambda_2.^2 .* sin(x(4))^2)-1).^2))).^2)
and then use the following parameters
x0 = [15,500,12,0.75*pi];
A = [];
b = [];
Aeq = [];
beq = [];
lb = [0,0,0,0];
ub = [inf, inf, inf, pi];
chi = fmincon(fun, x0,A,b,Aeq,beq,lb,ub,nonlcon)
function [c,ceq] = nonlcon(x,lambda_1,lambda_2)
c =1-(lambda_1.^2 .* cos(x(4)).^2 + lambda_2.^2 * sin(x(4)).^2) ;
ceq = [];
end
With these parameters, I can somewhat get close to my data points.
Now my questions:
I don’t think I understood c,ceq correctly. I used c to account for the constraint on I4, but I’m not sure if this was the right way to do it.
With the initial guess for x0, I can get close but it never seems to approach my curve nearly enough. How do I know if I have a good starting guess, and is fmincon even the right approach for this problem.
I have multiple data sets, for different stretch ratios (lambda_1:lambda_2: 1-1, 1-0.75, 0.75-1, 1-0.5,0.5-1) and since they are the same sample, I would like to use those datas to get one set of parameters for all of them. I tried to put all my data into a single vector, (1:30 would be the first data set, 31:^60 the second,…). This does not seem to work well. Should I find the solution for just one curve and than try to average over the parameters? As you guys can see, I am doing this parameter evaluation thing the first time ever and I would greatly appreciate help. fmincon, nonlinear, curve fitting, optimization MATLAB Answers — New Questions
Problem with direct calculation on table with std and “omitnan”
Since R2023a, it is possible to perform calculations directly on tables (and timetables) without extracting their data by indexing.
https://fr.mathworks.com/help/matlab/matlab_prog/direct-calculations-on-tables-and-timetables.html?searchHighlight=table&s_tid=srchtitle_table_9
I want use std directly on a numeric table where I can have nan.
For example :
load patients
T = table(Age,Height,Weight,Systolic,Diastolic)
mean(T,"omitnan")
It’s fine.
But why there is a problem with std(T,"omitnan") ?
% Applying the function ‘std’ to the variable ‘Age’ generated an error.
I can use std(T{:,:},"omitnan") or std(T.Variables,"omitnan") but I lost the possibility to work directly with my table.
Did I miss something ?
Do you have any suggestion ?
Thank you in advance.
SAINTHILLIER Jean MarieSince R2023a, it is possible to perform calculations directly on tables (and timetables) without extracting their data by indexing.
https://fr.mathworks.com/help/matlab/matlab_prog/direct-calculations-on-tables-and-timetables.html?searchHighlight=table&s_tid=srchtitle_table_9
I want use std directly on a numeric table where I can have nan.
For example :
load patients
T = table(Age,Height,Weight,Systolic,Diastolic)
mean(T,"omitnan")
It’s fine.
But why there is a problem with std(T,"omitnan") ?
% Applying the function ‘std’ to the variable ‘Age’ generated an error.
I can use std(T{:,:},"omitnan") or std(T.Variables,"omitnan") but I lost the possibility to work directly with my table.
Did I miss something ?
Do you have any suggestion ?
Thank you in advance.
SAINTHILLIER Jean Marie Since R2023a, it is possible to perform calculations directly on tables (and timetables) without extracting their data by indexing.
https://fr.mathworks.com/help/matlab/matlab_prog/direct-calculations-on-tables-and-timetables.html?searchHighlight=table&s_tid=srchtitle_table_9
I want use std directly on a numeric table where I can have nan.
For example :
load patients
T = table(Age,Height,Weight,Systolic,Diastolic)
mean(T,"omitnan")
It’s fine.
But why there is a problem with std(T,"omitnan") ?
% Applying the function ‘std’ to the variable ‘Age’ generated an error.
I can use std(T{:,:},"omitnan") or std(T.Variables,"omitnan") but I lost the possibility to work directly with my table.
Did I miss something ?
Do you have any suggestion ?
Thank you in advance.
SAINTHILLIER Jean Marie table, std MATLAB Answers — New Questions
Create and plot an oriented graph of a circuit from a netlist
Hello,
it should be a ridiculously trivial task, but I have to admit I’ve been stuck on it for a few months. Sadly, I’m not very good at Python either, so I’m coming here.
Assume that I have some circuit like the one below:
I want to read and parse a netlist such that I create a digraph object, which can later be used for testing subgraphs being a spanning tree and alike graph theoretic features. Prsing a netlist posses no difficulty, but it looks like the digraph function does not care about the order in my input cells and when I plot the graph, it is labeled wrongly.
I have spent weeks on it with no result. Can you see a easy solution how to turn it into a graph object and plot it accordingly?
Code below produces obvisouly wrong plot, for instance resistors, while the topoogy seems to be idnetified correctly. Edges/Nodes are mislabeled.
clear
close all
clc
netlist = {
‘R1 N001 0 R’;
‘R2 N002 N001 R’;
‘R3 0 N002 R’;
‘C1 N002 N001 C’;
‘C2 N001 0 C’;
‘C3 N002 0 C’;
‘L1 N002 N001 L’;
‘L2 0 N001 L’;
‘L3 0 N002 L’
};
elements = {};
sourceNodes = {};
targetNodes = {};
labels = {};
for i = 1:length(netlist)
parts = strsplit(netlist{i});
elements{end+1} = parts{1};
sourceNodes{end+1} = parts{2};
targetNodes{end+1} = parts{3};
labels{end+1} = [parts{4} ‘ – ‘ parts{1}];
end
edgeTable = table(sourceNodes’, targetNodes’, labels’, ‘VariableNames’, {‘EndNodes’, ‘EndNodes2’, ‘Label’});
G = digraph(edgeTable.EndNodes, edgeTable.EndNodes2);
G.Edges.Label = edgeTable.Label;
h = plot(G, ‘EdgeLabel’, G.Edges.Label, ‘NodeLabel’, G.Nodes.Name, ‘Layout’, ‘force’);Hello,
it should be a ridiculously trivial task, but I have to admit I’ve been stuck on it for a few months. Sadly, I’m not very good at Python either, so I’m coming here.
Assume that I have some circuit like the one below:
I want to read and parse a netlist such that I create a digraph object, which can later be used for testing subgraphs being a spanning tree and alike graph theoretic features. Prsing a netlist posses no difficulty, but it looks like the digraph function does not care about the order in my input cells and when I plot the graph, it is labeled wrongly.
I have spent weeks on it with no result. Can you see a easy solution how to turn it into a graph object and plot it accordingly?
Code below produces obvisouly wrong plot, for instance resistors, while the topoogy seems to be idnetified correctly. Edges/Nodes are mislabeled.
clear
close all
clc
netlist = {
‘R1 N001 0 R’;
‘R2 N002 N001 R’;
‘R3 0 N002 R’;
‘C1 N002 N001 C’;
‘C2 N001 0 C’;
‘C3 N002 0 C’;
‘L1 N002 N001 L’;
‘L2 0 N001 L’;
‘L3 0 N002 L’
};
elements = {};
sourceNodes = {};
targetNodes = {};
labels = {};
for i = 1:length(netlist)
parts = strsplit(netlist{i});
elements{end+1} = parts{1};
sourceNodes{end+1} = parts{2};
targetNodes{end+1} = parts{3};
labels{end+1} = [parts{4} ‘ – ‘ parts{1}];
end
edgeTable = table(sourceNodes’, targetNodes’, labels’, ‘VariableNames’, {‘EndNodes’, ‘EndNodes2’, ‘Label’});
G = digraph(edgeTable.EndNodes, edgeTable.EndNodes2);
G.Edges.Label = edgeTable.Label;
h = plot(G, ‘EdgeLabel’, G.Edges.Label, ‘NodeLabel’, G.Nodes.Name, ‘Layout’, ‘force’); Hello,
it should be a ridiculously trivial task, but I have to admit I’ve been stuck on it for a few months. Sadly, I’m not very good at Python either, so I’m coming here.
Assume that I have some circuit like the one below:
I want to read and parse a netlist such that I create a digraph object, which can later be used for testing subgraphs being a spanning tree and alike graph theoretic features. Prsing a netlist posses no difficulty, but it looks like the digraph function does not care about the order in my input cells and when I plot the graph, it is labeled wrongly.
I have spent weeks on it with no result. Can you see a easy solution how to turn it into a graph object and plot it accordingly?
Code below produces obvisouly wrong plot, for instance resistors, while the topoogy seems to be idnetified correctly. Edges/Nodes are mislabeled.
clear
close all
clc
netlist = {
‘R1 N001 0 R’;
‘R2 N002 N001 R’;
‘R3 0 N002 R’;
‘C1 N002 N001 C’;
‘C2 N001 0 C’;
‘C3 N002 0 C’;
‘L1 N002 N001 L’;
‘L2 0 N001 L’;
‘L3 0 N002 L’
};
elements = {};
sourceNodes = {};
targetNodes = {};
labels = {};
for i = 1:length(netlist)
parts = strsplit(netlist{i});
elements{end+1} = parts{1};
sourceNodes{end+1} = parts{2};
targetNodes{end+1} = parts{3};
labels{end+1} = [parts{4} ‘ – ‘ parts{1}];
end
edgeTable = table(sourceNodes’, targetNodes’, labels’, ‘VariableNames’, {‘EndNodes’, ‘EndNodes2’, ‘Label’});
G = digraph(edgeTable.EndNodes, edgeTable.EndNodes2);
G.Edges.Label = edgeTable.Label;
h = plot(G, ‘EdgeLabel’, G.Edges.Label, ‘NodeLabel’, G.Nodes.Name, ‘Layout’, ‘force’); digraph, circuit, netlist, spanning tree, graph plotting, spice MATLAB Answers — New Questions
Is it possible to realize self-supervised RL by adding auxiliary loss to the loss of Critic of PPO agent?
I am trying to realize self-supervised (SS) RL in MATLAB by using PPO agent. The SS RL can improve exploration and thereby enhance the convergence. In particular, it can be explained as follows:
At step , in addition to the original head of Critic that output the value via fullyConnectedLayer(1), there is an additional layer that is parallel to the original head of Critic and connected to the main body of critic, which outputs the the prediction of future state, denoted by , via fullyConnectedLayer(N) with N being the dimension of .
Then, such a prediction of future state will be used to calculate the SS loss by comparing it with the real future state, i.e., , where is the real future state.
Later, such a SS loss will be sampled and thereafter added to the original loss of Critic , i.e., 5-b in https://ww2.mathworks.cn/help/reinforcement-learning/ug/proximal-policy-optimization-agents.html, as follows
,
which requires to additionally add an auxiliary loss to the original loss of Critic.
So, is it possible to realize the above SS RL while avoiding significant modification in the source code of RL toolbox? Thank you!I am trying to realize self-supervised (SS) RL in MATLAB by using PPO agent. The SS RL can improve exploration and thereby enhance the convergence. In particular, it can be explained as follows:
At step , in addition to the original head of Critic that output the value via fullyConnectedLayer(1), there is an additional layer that is parallel to the original head of Critic and connected to the main body of critic, which outputs the the prediction of future state, denoted by , via fullyConnectedLayer(N) with N being the dimension of .
Then, such a prediction of future state will be used to calculate the SS loss by comparing it with the real future state, i.e., , where is the real future state.
Later, such a SS loss will be sampled and thereafter added to the original loss of Critic , i.e., 5-b in https://ww2.mathworks.cn/help/reinforcement-learning/ug/proximal-policy-optimization-agents.html, as follows
,
which requires to additionally add an auxiliary loss to the original loss of Critic.
So, is it possible to realize the above SS RL while avoiding significant modification in the source code of RL toolbox? Thank you! I am trying to realize self-supervised (SS) RL in MATLAB by using PPO agent. The SS RL can improve exploration and thereby enhance the convergence. In particular, it can be explained as follows:
At step , in addition to the original head of Critic that output the value via fullyConnectedLayer(1), there is an additional layer that is parallel to the original head of Critic and connected to the main body of critic, which outputs the the prediction of future state, denoted by , via fullyConnectedLayer(N) with N being the dimension of .
Then, such a prediction of future state will be used to calculate the SS loss by comparing it with the real future state, i.e., , where is the real future state.
Later, such a SS loss will be sampled and thereafter added to the original loss of Critic , i.e., 5-b in https://ww2.mathworks.cn/help/reinforcement-learning/ug/proximal-policy-optimization-agents.html, as follows
,
which requires to additionally add an auxiliary loss to the original loss of Critic.
So, is it possible to realize the above SS RL while avoiding significant modification in the source code of RL toolbox? Thank you! self-supervised rl, auxiliary loss, loss of critic, rlppoagent MATLAB Answers — New Questions
How to extract specific matrix after implemeting svd function
I want to solve PEB minimization problem in sort of RIS problem. So I have formulated SDP problem via ‘CVX’ and at the end of the CVX formulation, using built-in svd(or svds) function to extract RIS phase profile matrix F(with size M times T, M=# of RIS elements and T is # of transmissions). Optimal solution of CVX is X which has size M by M. And X is FF^H. From X F is extracted by using svds as size of M by T.
The code is below,
M = signal.M;
T = signal.T;
% k-th column of identity matrix
e1 = [1; 0; 0];
e2 = [0; 1; 0];
e3 = [0; 0; 1];
% define optimization problem
cvx_begin sdp
variable X(M, M) hermitian
variable u(3, 1)
minimize(sum(u))
subject to
[J_car(1:3, 1:3), e1; e1′, u(1)] >= 0;
[J_car(1:3, 1:3), e2; e2′, u(2)] >= 0;
[J_car(1:3, 1:3), e3; e3′, u(3)] >= 0;
trace(X) == M * T;
X >= 0;
cvx_end
optimX = X;
[U, S, V] = svds(optimX, T);
num_singular_values = min(size(S, 1), T);
optimF = U(:, 1:num_singular_values) * sqrt(S(1:num_singular_values, 1:num_singular_values));
end
and the optimization problem is:
Then my questions are:
Is it correct method using ‘svd’ to extract F(size M by T) from optimal solution X?
If not, what method can I try to? If possible, comment breif code for it.
It is not programming issue, but about mathematical, Is sum of all elements in auxiliary variable(objective for (12)) same as objective for (11)?I want to solve PEB minimization problem in sort of RIS problem. So I have formulated SDP problem via ‘CVX’ and at the end of the CVX formulation, using built-in svd(or svds) function to extract RIS phase profile matrix F(with size M times T, M=# of RIS elements and T is # of transmissions). Optimal solution of CVX is X which has size M by M. And X is FF^H. From X F is extracted by using svds as size of M by T.
The code is below,
M = signal.M;
T = signal.T;
% k-th column of identity matrix
e1 = [1; 0; 0];
e2 = [0; 1; 0];
e3 = [0; 0; 1];
% define optimization problem
cvx_begin sdp
variable X(M, M) hermitian
variable u(3, 1)
minimize(sum(u))
subject to
[J_car(1:3, 1:3), e1; e1′, u(1)] >= 0;
[J_car(1:3, 1:3), e2; e2′, u(2)] >= 0;
[J_car(1:3, 1:3), e3; e3′, u(3)] >= 0;
trace(X) == M * T;
X >= 0;
cvx_end
optimX = X;
[U, S, V] = svds(optimX, T);
num_singular_values = min(size(S, 1), T);
optimF = U(:, 1:num_singular_values) * sqrt(S(1:num_singular_values, 1:num_singular_values));
end
and the optimization problem is:
Then my questions are:
Is it correct method using ‘svd’ to extract F(size M by T) from optimal solution X?
If not, what method can I try to? If possible, comment breif code for it.
It is not programming issue, but about mathematical, Is sum of all elements in auxiliary variable(objective for (12)) same as objective for (11)? I want to solve PEB minimization problem in sort of RIS problem. So I have formulated SDP problem via ‘CVX’ and at the end of the CVX formulation, using built-in svd(or svds) function to extract RIS phase profile matrix F(with size M times T, M=# of RIS elements and T is # of transmissions). Optimal solution of CVX is X which has size M by M. And X is FF^H. From X F is extracted by using svds as size of M by T.
The code is below,
M = signal.M;
T = signal.T;
% k-th column of identity matrix
e1 = [1; 0; 0];
e2 = [0; 1; 0];
e3 = [0; 0; 1];
% define optimization problem
cvx_begin sdp
variable X(M, M) hermitian
variable u(3, 1)
minimize(sum(u))
subject to
[J_car(1:3, 1:3), e1; e1′, u(1)] >= 0;
[J_car(1:3, 1:3), e2; e2′, u(2)] >= 0;
[J_car(1:3, 1:3), e3; e3′, u(3)] >= 0;
trace(X) == M * T;
X >= 0;
cvx_end
optimX = X;
[U, S, V] = svds(optimX, T);
num_singular_values = min(size(S, 1), T);
optimF = U(:, 1:num_singular_values) * sqrt(S(1:num_singular_values, 1:num_singular_values));
end
and the optimization problem is:
Then my questions are:
Is it correct method using ‘svd’ to extract F(size M by T) from optimal solution X?
If not, what method can I try to? If possible, comment breif code for it.
It is not programming issue, but about mathematical, Is sum of all elements in auxiliary variable(objective for (12)) same as objective for (11)? svd, ris, mimo, cvx, optim MATLAB Answers — New Questions
Is there any utility to display message or variables in custom criteria script of simulink test ?
In custom criteria script of simulink test, the disp() doesnt work and so it is very hard to debug the script. I had to use error() and it doesnt support most of the types like structure, cell etc. Is there any utility available for debuging the script in custom criteria script ?In custom criteria script of simulink test, the disp() doesnt work and so it is very hard to debug the script. I had to use error() and it doesnt support most of the types like structure, cell etc. Is there any utility available for debuging the script in custom criteria script ? In custom criteria script of simulink test, the disp() doesnt work and so it is very hard to debug the script. I had to use error() and it doesnt support most of the types like structure, cell etc. Is there any utility available for debuging the script in custom criteria script ? simulink test, custom criteria script MATLAB Answers — New Questions
HDL Cosimulation with Cadence Xcelium setup
When running the example of "GettingStartedWithSimulinkHDLCosimExample" with Cadence Xcelium , I get these following messages.
Executing nclaunch tclstart commands…
xmsim(64): 22.09-s004: (c) Copyright 1995-2022 Cadence Design Systems, Inc.
xmsim: *W,NOMTDGUI: Multi-Threaded Dumping is disabled for interactive debug mode.
xmsim: *E,STRPIN: Could not initialize SimVision connection: SimVision/Indago process terminated before a connection was established.
ERROR: ld.so: object ‘/tools/matlab/R2023bU1/sys/os/glnxa64/libstdc++.so.6’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/tools/matlab/R2023bU1/sys/os/glnxa64/libstdc++.so.6’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/tools/matlab/R2023bU1/sys/os/glnxa64/libstdc++.so.6’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/tools/matlab/R2023bU1/sys/os/glnxa64/libstdc++.so.6’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/tools/matlab/R2023bU1/sys/os/glnxa64/libstdc++.so.6’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/tools/matlab/R2023bU1/sys/os/glnxa64/libstdc++.so.6’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/tools/matlab/R2023bU1/sys/os/glnxa64/libstdc++.so.6’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/tools/matlab/R2023bU1/sys/os/glnxa64/libstdc++.so.6’ from LD_PRELOAD cannot be preloaded: ignored.
/tools/cds/xceliummain_22.09.004_Linux/tools.lnx86/simvision/bin/64bit/simvision: line 48: cds_plat: command not found
/tools/cds/xceliummain_22.09.004_Linux/tools.lnx86/simvision/bin/64bit/simvision: line 101: /tools/cds/xceliummain_22.09.004_Linux/tools./simvision/bin/64bit/simvision.exe: No such file or directory
SimVision/Indago process terminated before a connection could be established.
while executing
"exec <@stdin >@stdout xmsim -gui rcosflt_rtl -64bit -input {@simvision {set w [waveform new]}} -input {@simvision {waveform add -using $w -signals rco…"
("uplevel" body line 1)
invoked from within
"uplevel 1 [join $args]"
(procedure "hdlsimulink" line 22)
invoked from within
"hdlsimulink rcosflt_rtl -64bit -socket 44014 -input "{@simvision {set w [waveform new]}}" -input "{@simvision {waveform add -using $w -signals rc…"
(file "compile_and_launch.tcl" line 66)
ERROR hit any key to exit xterm
Could you please guide me how to set up cosimulation with Cadence Xcelium?When running the example of "GettingStartedWithSimulinkHDLCosimExample" with Cadence Xcelium , I get these following messages.
Executing nclaunch tclstart commands…
xmsim(64): 22.09-s004: (c) Copyright 1995-2022 Cadence Design Systems, Inc.
xmsim: *W,NOMTDGUI: Multi-Threaded Dumping is disabled for interactive debug mode.
xmsim: *E,STRPIN: Could not initialize SimVision connection: SimVision/Indago process terminated before a connection was established.
ERROR: ld.so: object ‘/tools/matlab/R2023bU1/sys/os/glnxa64/libstdc++.so.6’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/tools/matlab/R2023bU1/sys/os/glnxa64/libstdc++.so.6’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/tools/matlab/R2023bU1/sys/os/glnxa64/libstdc++.so.6’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/tools/matlab/R2023bU1/sys/os/glnxa64/libstdc++.so.6’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/tools/matlab/R2023bU1/sys/os/glnxa64/libstdc++.so.6’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/tools/matlab/R2023bU1/sys/os/glnxa64/libstdc++.so.6’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/tools/matlab/R2023bU1/sys/os/glnxa64/libstdc++.so.6’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/tools/matlab/R2023bU1/sys/os/glnxa64/libstdc++.so.6’ from LD_PRELOAD cannot be preloaded: ignored.
/tools/cds/xceliummain_22.09.004_Linux/tools.lnx86/simvision/bin/64bit/simvision: line 48: cds_plat: command not found
/tools/cds/xceliummain_22.09.004_Linux/tools.lnx86/simvision/bin/64bit/simvision: line 101: /tools/cds/xceliummain_22.09.004_Linux/tools./simvision/bin/64bit/simvision.exe: No such file or directory
SimVision/Indago process terminated before a connection could be established.
while executing
"exec <@stdin >@stdout xmsim -gui rcosflt_rtl -64bit -input {@simvision {set w [waveform new]}} -input {@simvision {waveform add -using $w -signals rco…"
("uplevel" body line 1)
invoked from within
"uplevel 1 [join $args]"
(procedure "hdlsimulink" line 22)
invoked from within
"hdlsimulink rcosflt_rtl -64bit -socket 44014 -input "{@simvision {set w [waveform new]}}" -input "{@simvision {waveform add -using $w -signals rc…"
(file "compile_and_launch.tcl" line 66)
ERROR hit any key to exit xterm
Could you please guide me how to set up cosimulation with Cadence Xcelium? When running the example of "GettingStartedWithSimulinkHDLCosimExample" with Cadence Xcelium , I get these following messages.
Executing nclaunch tclstart commands…
xmsim(64): 22.09-s004: (c) Copyright 1995-2022 Cadence Design Systems, Inc.
xmsim: *W,NOMTDGUI: Multi-Threaded Dumping is disabled for interactive debug mode.
xmsim: *E,STRPIN: Could not initialize SimVision connection: SimVision/Indago process terminated before a connection was established.
ERROR: ld.so: object ‘/tools/matlab/R2023bU1/sys/os/glnxa64/libstdc++.so.6’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/tools/matlab/R2023bU1/sys/os/glnxa64/libstdc++.so.6’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/tools/matlab/R2023bU1/sys/os/glnxa64/libstdc++.so.6’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/tools/matlab/R2023bU1/sys/os/glnxa64/libstdc++.so.6’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/tools/matlab/R2023bU1/sys/os/glnxa64/libstdc++.so.6’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/tools/matlab/R2023bU1/sys/os/glnxa64/libstdc++.so.6’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/tools/matlab/R2023bU1/sys/os/glnxa64/libstdc++.so.6’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/tools/matlab/R2023bU1/sys/os/glnxa64/libstdc++.so.6’ from LD_PRELOAD cannot be preloaded: ignored.
/tools/cds/xceliummain_22.09.004_Linux/tools.lnx86/simvision/bin/64bit/simvision: line 48: cds_plat: command not found
/tools/cds/xceliummain_22.09.004_Linux/tools.lnx86/simvision/bin/64bit/simvision: line 101: /tools/cds/xceliummain_22.09.004_Linux/tools./simvision/bin/64bit/simvision.exe: No such file or directory
SimVision/Indago process terminated before a connection could be established.
while executing
"exec <@stdin >@stdout xmsim -gui rcosflt_rtl -64bit -input {@simvision {set w [waveform new]}} -input {@simvision {waveform add -using $w -signals rco…"
("uplevel" body line 1)
invoked from within
"uplevel 1 [join $args]"
(procedure "hdlsimulink" line 22)
invoked from within
"hdlsimulink rcosflt_rtl -64bit -socket 44014 -input "{@simvision {set w [waveform new]}}" -input "{@simvision {waveform add -using $w -signals rc…"
(file "compile_and_launch.tcl" line 66)
ERROR hit any key to exit xterm
Could you please guide me how to set up cosimulation with Cadence Xcelium? cosimulation, cadence, hldverifier MATLAB Answers — New Questions
MobileNetV1 & MobileNetV3 matlab code for detecting wafer map defect patterns
Give MobileNetV1 & MobileNetV3 matlab code for identifying defect wafer map patternsGive MobileNetV1 & MobileNetV3 matlab code for identifying defect wafer map patterns Give MobileNetV1 & MobileNetV3 matlab code for identifying defect wafer map patterns mobilenetv1 mobilenetv3 MATLAB Answers — New Questions
how can i show my data on thingsview free app?
i used the read api key to upload my data but it is showing invalid api key. kindly answeri used the read api key to upload my data but it is showing invalid api key. kindly answer i used the read api key to upload my data but it is showing invalid api key. kindly answer 🙂 MATLAB Answers — New Questions
Obtain information after text pattern
Dear all
I am dealing with files of extension .mat (not related to MatLab) like the one attached. I would like to be able to save in a variable the numerical value that appears after the text pattern "material[x]:damping-constant = 1.0" (so, in this case, 1). As you can see, here x can take values from 1 to 8, so it would be useful for me to have an array where each index position stores the the corresponding value.
Any ideas?Dear all
I am dealing with files of extension .mat (not related to MatLab) like the one attached. I would like to be able to save in a variable the numerical value that appears after the text pattern "material[x]:damping-constant = 1.0" (so, in this case, 1). As you can see, here x can take values from 1 to 8, so it would be useful for me to have an array where each index position stores the the corresponding value.
Any ideas? Dear all
I am dealing with files of extension .mat (not related to MatLab) like the one attached. I would like to be able to save in a variable the numerical value that appears after the text pattern "material[x]:damping-constant = 1.0" (so, in this case, 1). As you can see, here x can take values from 1 to 8, so it would be useful for me to have an array where each index position stores the the corresponding value.
Any ideas? information after text pattern MATLAB Answers — New Questions
how can i load multiple/all audio files(.wav) in matlab ? all files have different names.
i have a folder containing a number of audio files. i want to load them in a loop so that each audio signals can undergo some operations that i intend to perform.i have a folder containing a number of audio files. i want to load them in a loop so that each audio signals can undergo some operations that i intend to perform. i have a folder containing a number of audio files. i want to load them in a loop so that each audio signals can undergo some operations that i intend to perform. audio signal, loading multiple files, matlab MATLAB Answers — New Questions