Email: helpdesk@telkomuniversity.ac.id

This Portal for internal use only!

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • Visual Paradigm
  • IBM
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Office
      • Windows
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Categories
  • Microsoft
    • Microsoft Apps
    • Office
    • Operating System
    • VLS
    • Developer Tools
    • Productivity Tools
    • Database
    • AI + Machine Learning
    • Middleware System
    • Learning Services
    • Analytics
    • Networking
    • Compute
    • Security
    • Internet Of Things
  • Adobe
  • Matlab
  • Google
  • Visual Paradigm
  • WordPress
    • Plugin WP
    • Themes WP
  • Opensource
  • Others
More Categories Less Categories
  • Get Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • My Account
    • Download
    • Cart
    • Checkout
    • Login
  • About Us
    • Contact
    • Forum
    • Frequently Questions
    • Privacy Policy
  • Forum
    • News
      • Category
      • News Tag

iconTicket Service Desk

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • Visual Paradigm
  • IBM
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Office
      • Windows
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Menu
  • Home
    • Download Application Package Repository Telkom University
    • Application Package Repository Telkom University
    • Download Official License Telkom University
    • Download Installer Application Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • All Pack
    • Microsoft
      • Operating System
      • Productivity Tools
      • Developer Tools
      • Database
      • AI + Machine Learning
      • Middleware System
      • Networking
      • Compute
      • Security
      • Analytics
      • Internet Of Things
      • Learning Services
    • Microsoft Apps
      • VLS
    • Adobe
    • Matlab
    • WordPress
      • Themes WP
      • Plugin WP
    • Google
    • Opensource
    • Others
  • My account
    • Download
    • Get Pack
    • Cart
    • Checkout
  • News
    • Category
    • News Tag
  • Forum
  • About Us
    • Privacy Policy
    • Frequently Questions
    • Contact
Home/Matlab

Category: Matlab

Category Archives: Matlab

Matlab News Blog From https://blogs.mathworks.com/

XML EDIT attribute value
Matlab

XML EDIT attribute value

/ 2025-01-08

My question might seem dumb but I can’t seem to find the answer: How can I edit certain values on an xml file that already exists?
I want to edit all the attributes values with values coming from an excel sheet. Is that possible?
Thanks!My question might seem dumb but I can’t seem to find the answer: How can I edit certain values on an xml file that already exists?
I want to edit all the attributes values with values coming from an excel sheet. Is that possible?
Thanks! My question might seem dumb but I can’t seem to find the answer: How can I edit certain values on an xml file that already exists?
I want to edit all the attributes values with values coming from an excel sheet. Is that possible?
Thanks! xml, xmledit MATLAB Answers — New Questions

​

matlab calculation area circular
Matlab

matlab calculation area circular

/ 2025-01-08

I have a signal and want to calculate the area. The problem is that i want to make a loop with decimal step, because the length is 1189,58
Any ideas how to proceed with the loop?I have a signal and want to calculate the area. The problem is that i want to make a loop with decimal step, because the length is 1189,58
Any ideas how to proceed with the loop? I have a signal and want to calculate the area. The problem is that i want to make a loop with decimal step, because the length is 1189,58
Any ideas how to proceed with the loop? range, area MATLAB Answers — New Questions

​

Is it possible to use MATLAB on slave computer/device for communication to host computer via serial MODBUS (RTU)
Matlab

Is it possible to use MATLAB on slave computer/device for communication to host computer via serial MODBUS (RTU)

/ 2025-01-08

Can I communicate with the host/master via serial port (MODBUS ASCII/RTU) using MATLAB on the slave computer, i.e. I need to wait for a request from the host/master, receive it when it comes and send back the requested data to the host. I found how this can implemented for MODBUS TCP/IP, but I did not find how to implement that for MODBUS ASCII/RTU (RS232, RS485). All MATLAB functions for serial port communication seem to be for the case when the code runs on the host computer. My MATLAB code runs on the slave device (processor/computer which controls the analytical instrument) and I need it to send the data when requested to the host (SCADA).Can I communicate with the host/master via serial port (MODBUS ASCII/RTU) using MATLAB on the slave computer, i.e. I need to wait for a request from the host/master, receive it when it comes and send back the requested data to the host. I found how this can implemented for MODBUS TCP/IP, but I did not find how to implement that for MODBUS ASCII/RTU (RS232, RS485). All MATLAB functions for serial port communication seem to be for the case when the code runs on the host computer. My MATLAB code runs on the slave device (processor/computer which controls the analytical instrument) and I need it to send the data when requested to the host (SCADA). Can I communicate with the host/master via serial port (MODBUS ASCII/RTU) using MATLAB on the slave computer, i.e. I need to wait for a request from the host/master, receive it when it comes and send back the requested data to the host. I found how this can implemented for MODBUS TCP/IP, but I did not find how to implement that for MODBUS ASCII/RTU (RS232, RS485). All MATLAB functions for serial port communication seem to be for the case when the code runs on the host computer. My MATLAB code runs on the slave device (processor/computer which controls the analytical instrument) and I need it to send the data when requested to the host (SCADA). serial port, modbus, modbus ascii, modbus rtu, modbus slave, modbus host, rs485, rs232 MATLAB Answers — New Questions

​

Convergence path error,Variables of this type do not support indexing with points.
Matlab

Convergence path error,Variables of this type do not support indexing with points.

/ 2025-01-08

I have a new problem, I obtain aspen convergence in the connection operation between aspen and matlab, my code is:
Conv = aspen.Tree.FindNode("DataResults SummaryRun-StatusOutputPER_ERROR");
I also found the corresponding path in aspen, but the code is wrong, At the same time, I have checked that CSDN does not support indexing with points for variables of this type, but when I change the code to:
Conv = Aspen.Tree.FindNode("DataResults SummaryRun-StatusOutputPER_ERROR");
ConvValue = Conv.Value;
I still get an errorI have a new problem, I obtain aspen convergence in the connection operation between aspen and matlab, my code is:
Conv = aspen.Tree.FindNode("DataResults SummaryRun-StatusOutputPER_ERROR");
I also found the corresponding path in aspen, but the code is wrong, At the same time, I have checked that CSDN does not support indexing with points for variables of this type, but when I change the code to:
Conv = Aspen.Tree.FindNode("DataResults SummaryRun-StatusOutputPER_ERROR");
ConvValue = Conv.Value;
I still get an error I have a new problem, I obtain aspen convergence in the connection operation between aspen and matlab, my code is:
Conv = aspen.Tree.FindNode("DataResults SummaryRun-StatusOutputPER_ERROR");
I also found the corresponding path in aspen, but the code is wrong, At the same time, I have checked that CSDN does not support indexing with points for variables of this type, but when I change the code to:
Conv = Aspen.Tree.FindNode("DataResults SummaryRun-StatusOutputPER_ERROR");
ConvValue = Conv.Value;
I still get an error aspen,matlab MATLAB Answers — New Questions

​

Closing windows CMD window after executing system and run through a certain algorithm
Matlab

Closing windows CMD window after executing system and run through a certain algorithm

/ 2025-01-08

I want to use ‘system’ to open another software in cmd as well as forming a java socket between them to allow exchanging datas for calculation, as shown in the code below
% command to execute in cmd to form socket
commandString = strcat(‘"’, this.FreeFlyerPath, ‘FreeFlyer.exe"’, …
‘ -r -mp "’, this.MissionPlanPath, ‘sample.MissionPlan"’, …
sprintf(‘ -ui %d -ui %d -ui %s &’, portNum(1), portNum(2), this.terminationCode));

system( commandString );
%
%
%
%
% some algorithms
%
%
%

% how to close the cmd?
However, the function has to be looped multiple times, that means the cmd windows keep popping out like a virus without exiting. I tried system(‘exit’) and it does not work. May I know the correct way to close the cmd window after executed the function?I want to use ‘system’ to open another software in cmd as well as forming a java socket between them to allow exchanging datas for calculation, as shown in the code below
% command to execute in cmd to form socket
commandString = strcat(‘"’, this.FreeFlyerPath, ‘FreeFlyer.exe"’, …
‘ -r -mp "’, this.MissionPlanPath, ‘sample.MissionPlan"’, …
sprintf(‘ -ui %d -ui %d -ui %s &’, portNum(1), portNum(2), this.terminationCode));

system( commandString );
%
%
%
%
% some algorithms
%
%
%

% how to close the cmd?
However, the function has to be looped multiple times, that means the cmd windows keep popping out like a virus without exiting. I tried system(‘exit’) and it does not work. May I know the correct way to close the cmd window after executed the function? I want to use ‘system’ to open another software in cmd as well as forming a java socket between them to allow exchanging datas for calculation, as shown in the code below
% command to execute in cmd to form socket
commandString = strcat(‘"’, this.FreeFlyerPath, ‘FreeFlyer.exe"’, …
‘ -r -mp "’, this.MissionPlanPath, ‘sample.MissionPlan"’, …
sprintf(‘ -ui %d -ui %d -ui %s &’, portNum(1), portNum(2), this.terminationCode));

system( commandString );
%
%
%
%
% some algorithms
%
%
%

% how to close the cmd?
However, the function has to be looped multiple times, that means the cmd windows keep popping out like a virus without exiting. I tried system(‘exit’) and it does not work. May I know the correct way to close the cmd window after executed the function? system, cmd, exit MATLAB Answers — New Questions

​

Problem in applying Genetic algorithm solver in matlab while solving the electric bus scheduling problem
Matlab

Problem in applying Genetic algorithm solver in matlab while solving the electric bus scheduling problem

/ 2025-01-08

I am using a Genetic Algorithm (GA) solver in MATLAB to solve the electric bus scheduling problem. The objective function is designed to minimize the cost of electric buses and chargers while incorporating vehicle flow and charging constraints. However, when I apply the solver, it seems to ignore the charging constraints. It only outputs the number of electric buses along with their schedules, without assigning any buses to chargers. The output for chargers consistently shows a value of zero. When I tested the same dataset using CPLEX, it successfully assigned electric buses to chargers. How can I resolve this issue?
% Solver options
options = optimoptions(‘ga’, …
‘Display’, ‘iter’, … % Display iteration details
‘PlotFcn’, ‘gaplotbestf’, … % Plot GA progress
‘MaxTime’, 5000, … % Maximum runtime in seconds
‘PopulationSize’, 100, … % GA population size
‘CrossoverFraction’, 0.8); % Fraction for crossover

% Solve the optimization problem
[sol, fval, exitflag, output] = solve(Busschedulling_A, ‘Solver’, ‘ga’, ‘Options’, options);I am using a Genetic Algorithm (GA) solver in MATLAB to solve the electric bus scheduling problem. The objective function is designed to minimize the cost of electric buses and chargers while incorporating vehicle flow and charging constraints. However, when I apply the solver, it seems to ignore the charging constraints. It only outputs the number of electric buses along with their schedules, without assigning any buses to chargers. The output for chargers consistently shows a value of zero. When I tested the same dataset using CPLEX, it successfully assigned electric buses to chargers. How can I resolve this issue?
% Solver options
options = optimoptions(‘ga’, …
‘Display’, ‘iter’, … % Display iteration details
‘PlotFcn’, ‘gaplotbestf’, … % Plot GA progress
‘MaxTime’, 5000, … % Maximum runtime in seconds
‘PopulationSize’, 100, … % GA population size
‘CrossoverFraction’, 0.8); % Fraction for crossover

% Solve the optimization problem
[sol, fval, exitflag, output] = solve(Busschedulling_A, ‘Solver’, ‘ga’, ‘Options’, options); I am using a Genetic Algorithm (GA) solver in MATLAB to solve the electric bus scheduling problem. The objective function is designed to minimize the cost of electric buses and chargers while incorporating vehicle flow and charging constraints. However, when I apply the solver, it seems to ignore the charging constraints. It only outputs the number of electric buses along with their schedules, without assigning any buses to chargers. The output for chargers consistently shows a value of zero. When I tested the same dataset using CPLEX, it successfully assigned electric buses to chargers. How can I resolve this issue?
% Solver options
options = optimoptions(‘ga’, …
‘Display’, ‘iter’, … % Display iteration details
‘PlotFcn’, ‘gaplotbestf’, … % Plot GA progress
‘MaxTime’, 5000, … % Maximum runtime in seconds
‘PopulationSize’, 100, … % GA population size
‘CrossoverFraction’, 0.8); % Fraction for crossover

% Solve the optimization problem
[sol, fval, exitflag, output] = solve(Busschedulling_A, ‘Solver’, ‘ga’, ‘Options’, options); genetic algorithm, matlab, optimization, programming MATLAB Answers — New Questions

​

Warning: Parameter object’s DataType property has been set while its Value is not double precision.
Matlab

Warning: Parameter object’s DataType property has been set while its Value is not double precision.

/ 2025-01-08

I have this warnings in matlab
Warning: Parameter object’s DataType property has been set while its Value is not double precision. Converting Value to real-world value (double precision).

I use .m file when declare parameter
and delare like this
Y.Value = [fi([0,10,10,0,0,0,0,0,0,0], 1, 16, 0.01, 0)];
When I enterend Y Value in command Window say like this
Parameter with properties:

Value: [0 10 10 0 0 0 0 0 0 0]
CoderInfo: [1×1 Simulink.CoderInfo]
Description: ‘-‘
DataType: ‘fixdt(0,16,0.01,0)’
Min: []
Max: []
Unit: ”
Complexity: ‘real’
Dimensions: [1 10]

Why this warning happens?I have this warnings in matlab
Warning: Parameter object’s DataType property has been set while its Value is not double precision. Converting Value to real-world value (double precision).

I use .m file when declare parameter
and delare like this
Y.Value = [fi([0,10,10,0,0,0,0,0,0,0], 1, 16, 0.01, 0)];
When I enterend Y Value in command Window say like this
Parameter with properties:

Value: [0 10 10 0 0 0 0 0 0 0]
CoderInfo: [1×1 Simulink.CoderInfo]
Description: ‘-‘
DataType: ‘fixdt(0,16,0.01,0)’
Min: []
Max: []
Unit: ”
Complexity: ‘real’
Dimensions: [1 10]

Why this warning happens? I have this warnings in matlab
Warning: Parameter object’s DataType property has been set while its Value is not double precision. Converting Value to real-world value (double precision).

I use .m file when declare parameter
and delare like this
Y.Value = [fi([0,10,10,0,0,0,0,0,0,0], 1, 16, 0.01, 0)];
When I enterend Y Value in command Window say like this
Parameter with properties:

Value: [0 10 10 0 0 0 0 0 0 0]
CoderInfo: [1×1 Simulink.CoderInfo]
Description: ‘-‘
DataType: ‘fixdt(0,16,0.01,0)’
Min: []
Max: []
Unit: ”
Complexity: ‘real’
Dimensions: [1 10]

Why this warning happens? simulink, matlab MATLAB Answers — New Questions

​

How to stop command window from pasting in previous commands?
Matlab

How to stop command window from pasting in previous commands?

/ 2025-01-08

I’ve been encountering a strange issue with my command windows as of recent. For some reason whenever I type something in, it will provide to paste previous prompts from the window about 20 times over. This results in the workspace becoming unusable. Does anyone know what might be causing this? I’m new to the system so its difficult for me to troubleshoot.I’ve been encountering a strange issue with my command windows as of recent. For some reason whenever I type something in, it will provide to paste previous prompts from the window about 20 times over. This results in the workspace becoming unusable. Does anyone know what might be causing this? I’m new to the system so its difficult for me to troubleshoot. I’ve been encountering a strange issue with my command windows as of recent. For some reason whenever I type something in, it will provide to paste previous prompts from the window about 20 times over. This results in the workspace becoming unusable. Does anyone know what might be causing this? I’m new to the system so its difficult for me to troubleshoot. help, matlab MATLAB Answers — New Questions

​

accessIntervals Function: Subscripting into a Table Using One Subscript Error
Matlab

accessIntervals Function: Subscripting into a Table Using One Subscript Error

/ 2025-01-08

Problem Description:
I am working on a MATLAB project involving the Satellite Communications Toolbox. My script uses the accessIntervals function to compute access intervals for satellites and ground stations. However, I consistently encounter the following error:
sql
Copy code
Subscripting into a table using one subscript (as in t(i)) is not supported. Specify a row subscript and a variable subscript, as in t(rows,vars). To select variables, use t(:,i) or for one variable t.(i). To select rows, use t(i,:).

Steps to Reproduce:
I created a satellite scenario with the following setup:matlabCopy codestartTime = datetime(2024, 1, 6, 23, 23, 0);
stopTime = startTime + hours(24);
sampleTime = 60;
sc = satelliteScenario(startTime, stopTime, sampleTime);
sat = walkerDelta(sc, 570e3 + 6378.14e3, 70, 720, 36, 1, ArgumentOfLatitude=15, Name="Starlink");
gs = groundStation(sc, "Name", "Test Station", "Latitude", -35.40139, "Longitude", 148.98167);
ac = access(sat, gs);

I attempted to call accessIntervals for the Access object:matlabCopy codeTest = accessIntervals(ac(1));

The error occurs for all Access objects (ac).
Debugging Steps Taken:
I confirmed the Access objects (ac) are valid and properly initialized:matlabCopy codeAccess Object 1:
Access with properties:
Sequence: [1 721]
LineWidth: 3
LineColor: [0.3922 0.8314 0.0745]

The error persists for all Access objects.
Questions:
Is this a known issue with accessIntervals or the Satellite Communications Toolbox?
How can I resolve or work around this error to compute access intervals?
Are there alternative methods to compute satellite-ground station access intervals if accessIntervals cannot be used?
Environment: MatlabonlineProblem Description:
I am working on a MATLAB project involving the Satellite Communications Toolbox. My script uses the accessIntervals function to compute access intervals for satellites and ground stations. However, I consistently encounter the following error:
sql
Copy code
Subscripting into a table using one subscript (as in t(i)) is not supported. Specify a row subscript and a variable subscript, as in t(rows,vars). To select variables, use t(:,i) or for one variable t.(i). To select rows, use t(i,:).

Steps to Reproduce:
I created a satellite scenario with the following setup:matlabCopy codestartTime = datetime(2024, 1, 6, 23, 23, 0);
stopTime = startTime + hours(24);
sampleTime = 60;
sc = satelliteScenario(startTime, stopTime, sampleTime);
sat = walkerDelta(sc, 570e3 + 6378.14e3, 70, 720, 36, 1, ArgumentOfLatitude=15, Name="Starlink");
gs = groundStation(sc, "Name", "Test Station", "Latitude", -35.40139, "Longitude", 148.98167);
ac = access(sat, gs);

I attempted to call accessIntervals for the Access object:matlabCopy codeTest = accessIntervals(ac(1));

The error occurs for all Access objects (ac).
Debugging Steps Taken:
I confirmed the Access objects (ac) are valid and properly initialized:matlabCopy codeAccess Object 1:
Access with properties:
Sequence: [1 721]
LineWidth: 3
LineColor: [0.3922 0.8314 0.0745]

The error persists for all Access objects.
Questions:
Is this a known issue with accessIntervals or the Satellite Communications Toolbox?
How can I resolve or work around this error to compute access intervals?
Are there alternative methods to compute satellite-ground station access intervals if accessIntervals cannot be used?
Environment: Matlabonline Problem Description:
I am working on a MATLAB project involving the Satellite Communications Toolbox. My script uses the accessIntervals function to compute access intervals for satellites and ground stations. However, I consistently encounter the following error:
sql
Copy code
Subscripting into a table using one subscript (as in t(i)) is not supported. Specify a row subscript and a variable subscript, as in t(rows,vars). To select variables, use t(:,i) or for one variable t.(i). To select rows, use t(i,:).

Steps to Reproduce:
I created a satellite scenario with the following setup:matlabCopy codestartTime = datetime(2024, 1, 6, 23, 23, 0);
stopTime = startTime + hours(24);
sampleTime = 60;
sc = satelliteScenario(startTime, stopTime, sampleTime);
sat = walkerDelta(sc, 570e3 + 6378.14e3, 70, 720, 36, 1, ArgumentOfLatitude=15, Name="Starlink");
gs = groundStation(sc, "Name", "Test Station", "Latitude", -35.40139, "Longitude", 148.98167);
ac = access(sat, gs);

I attempted to call accessIntervals for the Access object:matlabCopy codeTest = accessIntervals(ac(1));

The error occurs for all Access objects (ac).
Debugging Steps Taken:
I confirmed the Access objects (ac) are valid and properly initialized:matlabCopy codeAccess Object 1:
Access with properties:
Sequence: [1 721]
LineWidth: 3
LineColor: [0.3922 0.8314 0.0745]

The error persists for all Access objects.
Questions:
Is this a known issue with accessIntervals or the Satellite Communications Toolbox?
How can I resolve or work around this error to compute access intervals?
Are there alternative methods to compute satellite-ground station access intervals if accessIntervals cannot be used?
Environment: Matlabonline accessintervals satellite toolbox satellite scenar, table indexing, error handling MATLAB Answers — New Questions

​

The lane markings appears at the right side of each road, but according to the official tutorial it should be at the road center.
Matlab

The lane markings appears at the right side of each road, but according to the official tutorial it should be at the road center.

/ 2025-01-08

the picture is below.I can’t find how to set the lane markings(the yellow lane in the picture) to the road center it needed. thanks for your warm help.the picture is below.I can’t find how to set the lane markings(the yellow lane in the picture) to the road center it needed. thanks for your warm help. the picture is below.I can’t find how to set the lane markings(the yellow lane in the picture) to the road center it needed. thanks for your warm help. driving scenario designer MATLAB Answers — New Questions

​

Edit Code Initialization under Mask editor
Matlab

Edit Code Initialization under Mask editor

/ 2025-01-08

I am creating the mask for my simulink block and I need to add the Initiallization code to it. Unfortumatelly I can’t edit (add) code within the mask editor; it’s grayed and not editable, disabled.

How can I access this, and add the initialization code to it?

Thank you.I am creating the mask for my simulink block and I need to add the Initiallization code to it. Unfortumatelly I can’t edit (add) code within the mask editor; it’s grayed and not editable, disabled.

How can I access this, and add the initialization code to it?

Thank you. I am creating the mask for my simulink block and I need to add the Initiallization code to it. Unfortumatelly I can’t edit (add) code within the mask editor; it’s grayed and not editable, disabled.

How can I access this, and add the initialization code to it?

Thank you. initialization under mask editor MATLAB Answers — New Questions

​

Is it possible to generate code for cloud computing platforms (i.e. Azure, AWS)?
Matlab

Is it possible to generate code for cloud computing platforms (i.e. Azure, AWS)?

/ 2025-01-08

I would like to generate code from a Simulink model in a cloud computing platform. Is it possible?
Other option: is it possible to convert the generated C code from Simulink in other language (i.e. Python, Julia, R)?I would like to generate code from a Simulink model in a cloud computing platform. Is it possible?
Other option: is it possible to convert the generated C code from Simulink in other language (i.e. Python, Julia, R)? I would like to generate code from a Simulink model in a cloud computing platform. Is it possible?
Other option: is it possible to convert the generated C code from Simulink in other language (i.e. Python, Julia, R)? cloud, code generation, simulink, python MATLAB Answers — New Questions

​

Extract and sort size of matrix where in the  cell
Matlab

Extract and sort size of matrix where in the cell

/ 2025-01-08

clc;clear;close all

im= [0 0 0 0 0 0 0 0 0 0
0 0 1 1 1 1 1 1 0 0
0 0 1 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0];

cc=bwconncomp(im);

for i=1:cc.NumObjects
CC{i}=cc.PixelIdxList{i}
end

Size=zeros(1,cc.NumObjects);
for j=1:cc.NumObjects

Size(:,i)=size(cell2mat(CC(j)))
endclc;clear;close all

im= [0 0 0 0 0 0 0 0 0 0
0 0 1 1 1 1 1 1 0 0
0 0 1 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0];

cc=bwconncomp(im);

for i=1:cc.NumObjects
CC{i}=cc.PixelIdxList{i}
end

Size=zeros(1,cc.NumObjects);
for j=1:cc.NumObjects

Size(:,i)=size(cell2mat(CC(j)))
end clc;clear;close all

im= [0 0 0 0 0 0 0 0 0 0
0 0 1 1 1 1 1 1 0 0
0 0 1 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0];

cc=bwconncomp(im);

for i=1:cc.NumObjects
CC{i}=cc.PixelIdxList{i}
end

Size=zeros(1,cc.NumObjects);
for j=1:cc.NumObjects

Size(:,i)=size(cell2mat(CC(j)))
end for loop MATLAB Answers — New Questions

​

How to calculate the PSNR of video sequence?
Matlab

How to calculate the PSNR of video sequence?

/ 2025-01-08

Hi there,
I want to calculate the PSNR value between two videos. One video is original and another one is watermarked video. The watermarked video has some watermarked frame. I have calculated PSNR of each frame one at a time of both of the videos, and calsulate the average of it, but unfortunately I get the "Inf" value of PSNR.
Again, I have also tried to calculate the PSNR of exactly two videos. As a result, I got the PSNR of 40 dB. In fact, the result must be 99.99
Any help must be appreciated.
Thanks in advance.
The code I have written to calculate the PSNR of two idential videos
clc;
output_folder = ‘D:Matlab book and filesSLTAkiyo_frames_journal’;

vidObj1 = VideoReader(‘akiyo_cif_x264.mp4’);
vidObj2 = VideoReader(‘akiyo_cif_x264_Copy.mp4’);

EnumFrames=0;
Extframe = cell(1,300) ;
frame = cell(1,300) ;
numFrames1 = 0;
numFrames2 = 0;

while hasFrame(vidObj1)
F1 = readFrame(vidObj1);
numFrames1 = numFrames1 + 1;
frame{numFrames1} = F ;
numFrames1

while hasFrame(vidObj2)
F2 = readFrame(vidObj2);
numFrames2 = numFrames2 + 1;
Extframe{numFrames2}=F2;
end
numFrames2
for i= 1:300
Extframe{i}= getframe;
frame{i}= getframe;
fprintf ("The PSNR of frame %d = %.2f n", i , psnr(frame2im(Extframe{i}),frame2im(frame{i})))
end

OUTPUT
The PSNR of frame 1 = Inf
The PSNR of frame 2 = Inf
The PSNR of frame 3 = Inf
The PSNR of frame 4 = Inf
The PSNR of frame 5 = Inf
The PSNR of frame 6 = Inf
The PSNR of frame 7 = Inf
The PSNR of frame 8 = Inf
The PSNR of frame 9 = Inf
The PSNR of frame 10 = Inf
……………………………………..
………………………………………
……………………………………..
The PSNR of frame 300 = InfHi there,
I want to calculate the PSNR value between two videos. One video is original and another one is watermarked video. The watermarked video has some watermarked frame. I have calculated PSNR of each frame one at a time of both of the videos, and calsulate the average of it, but unfortunately I get the "Inf" value of PSNR.
Again, I have also tried to calculate the PSNR of exactly two videos. As a result, I got the PSNR of 40 dB. In fact, the result must be 99.99
Any help must be appreciated.
Thanks in advance.
The code I have written to calculate the PSNR of two idential videos
clc;
output_folder = ‘D:Matlab book and filesSLTAkiyo_frames_journal’;

vidObj1 = VideoReader(‘akiyo_cif_x264.mp4’);
vidObj2 = VideoReader(‘akiyo_cif_x264_Copy.mp4’);

EnumFrames=0;
Extframe = cell(1,300) ;
frame = cell(1,300) ;
numFrames1 = 0;
numFrames2 = 0;

while hasFrame(vidObj1)
F1 = readFrame(vidObj1);
numFrames1 = numFrames1 + 1;
frame{numFrames1} = F ;
numFrames1

while hasFrame(vidObj2)
F2 = readFrame(vidObj2);
numFrames2 = numFrames2 + 1;
Extframe{numFrames2}=F2;
end
numFrames2
for i= 1:300
Extframe{i}= getframe;
frame{i}= getframe;
fprintf ("The PSNR of frame %d = %.2f n", i , psnr(frame2im(Extframe{i}),frame2im(frame{i})))
end

OUTPUT
The PSNR of frame 1 = Inf
The PSNR of frame 2 = Inf
The PSNR of frame 3 = Inf
The PSNR of frame 4 = Inf
The PSNR of frame 5 = Inf
The PSNR of frame 6 = Inf
The PSNR of frame 7 = Inf
The PSNR of frame 8 = Inf
The PSNR of frame 9 = Inf
The PSNR of frame 10 = Inf
……………………………………..
………………………………………
……………………………………..
The PSNR of frame 300 = Inf Hi there,
I want to calculate the PSNR value between two videos. One video is original and another one is watermarked video. The watermarked video has some watermarked frame. I have calculated PSNR of each frame one at a time of both of the videos, and calsulate the average of it, but unfortunately I get the "Inf" value of PSNR.
Again, I have also tried to calculate the PSNR of exactly two videos. As a result, I got the PSNR of 40 dB. In fact, the result must be 99.99
Any help must be appreciated.
Thanks in advance.
The code I have written to calculate the PSNR of two idential videos
clc;
output_folder = ‘D:Matlab book and filesSLTAkiyo_frames_journal’;

vidObj1 = VideoReader(‘akiyo_cif_x264.mp4’);
vidObj2 = VideoReader(‘akiyo_cif_x264_Copy.mp4’);

EnumFrames=0;
Extframe = cell(1,300) ;
frame = cell(1,300) ;
numFrames1 = 0;
numFrames2 = 0;

while hasFrame(vidObj1)
F1 = readFrame(vidObj1);
numFrames1 = numFrames1 + 1;
frame{numFrames1} = F ;
numFrames1

while hasFrame(vidObj2)
F2 = readFrame(vidObj2);
numFrames2 = numFrames2 + 1;
Extframe{numFrames2}=F2;
end
numFrames2
for i= 1:300
Extframe{i}= getframe;
frame{i}= getframe;
fprintf ("The PSNR of frame %d = %.2f n", i , psnr(frame2im(Extframe{i}),frame2im(frame{i})))
end

OUTPUT
The PSNR of frame 1 = Inf
The PSNR of frame 2 = Inf
The PSNR of frame 3 = Inf
The PSNR of frame 4 = Inf
The PSNR of frame 5 = Inf
The PSNR of frame 6 = Inf
The PSNR of frame 7 = Inf
The PSNR of frame 8 = Inf
The PSNR of frame 9 = Inf
The PSNR of frame 10 = Inf
……………………………………..
………………………………………
……………………………………..
The PSNR of frame 300 = Inf video watermatrking, video processing, watermarking MATLAB Answers — New Questions

​

Why is my transformer training erroring out, with the following message “Error using trainnet (line 46)”
Matlab

Why is my transformer training erroring out, with the following message “Error using trainnet (line 46)”

/ 2025-01-08

The full error message reads "Error using trainnet (line 46)
The number of mini-batch queue outputs (2) must match the number of network inputs plus
the number of network outputs (4)."
I’m using an arrayDatastore to pass the predictors (x2) and the targets(x2) to the transformer model. Both predictors have 410 features, one of the targets has 410 features and the other target is a scalar function.
Code to generate the dummy predictor and target data is pasted below:
%——————————————————————–
% data generation for encoder
numObs = 10;
seqLen = vocabSize;
x_enc = randi([1,10],[seqLen,numObs]);
y_enc = zeros(numObs,1);
for i = 1:numObs
idx = x_enc(1:2,i);
y_enc(i,:) = sum(x_enc(idx,i));
end
x_enc = num2cell(x_enc’,2);
y_enc = num2cell(y_enc)’;
x_1 = x_enc;
y_2 = y_enc’;
% data generation for decoder
x_series = randi([1,10],[seqLen,numObs]);
y_series = sin(rand([seqLen,numObs]));
x_dec = x_series(:,1:end)’;
y_dec = y_series(:,1:end)’;
x_dec = num2cell(x_dec,2); x_2 = x_dec;
y_dec = num2cell(y_dec,2); y_1 = y_dec;
cell_data = {}; cell_data = [cell_data x_1 x_2 y_1 y_2];
dstrain = arrayDatastore(cell_data,’OutputType’,’same’);
%——————————————————————-
cell_data is of the form:
cell_data

cell_data =

10×4 cell array

{1×410 double} {1×410 double} {1×410 double} {[ 8]}
{1×410 double} {1×410 double} {1×410 double} {[10]}
{1×410 double} {1×410 double} {1×410 double} {[13]}
{1×410 double} {1×410 double} {1×410 double} {[20]}
{1×410 double} {1×410 double} {1×410 double} {[ 7]}
{1×410 double} {1×410 double} {1×410 double} {[ 8]}
{1×410 double} {1×410 double} {1×410 double} {[17]}
{1×410 double} {1×410 double} {1×410 double} {[ 6]}
{1×410 double} {1×410 double} {1×410 double} {[11]}
{1×410 double} {1×410 double} {1×410 double} {[ 8]}

If I were to use readall(dstrain) to read the datastore, I get the same format as cell_data:
fds = readall(dstrain)

fds =

10×4 cell array

{1×410 double} {1×410 double} {1×410 double} {[ 8]}
{1×410 double} {1×410 double} {1×410 double} {[10]}
{1×410 double} {1×410 double} {1×410 double} {[13]}
{1×410 double} {1×410 double} {1×410 double} {[20]}
{1×410 double} {1×410 double} {1×410 double} {[ 7]}
{1×410 double} {1×410 double} {1×410 double} {[ 8]}
{1×410 double} {1×410 double} {1×410 double} {[17]}
{1×410 double} {1×410 double} {1×410 double} {[ 6]}
{1×410 double} {1×410 double} {1×410 double} {[11]}
{1×410 double} {1×410 double} {1×410 double} {[ 8]}

Finally, if I use minibatchqueue to create a minibatch of datastore ‘dstrain’, I get:
mbq = minibatchqueue(dstrain)

mbq =

minibatchqueue with 4 outputs and properties:

Mini-batch creation:
MiniBatchSize: 10
PartialMiniBatch: ‘return’
MiniBatchFcn: ‘collate’
PreprocessingEnvironment: ‘serial’

Outputs:
OutputCast: {‘single’ ‘single’ ‘single’ ‘single’}
OutputAsDlarray: [1 1 1 1]
MiniBatchFormat: {” ” ” ”}
OutputEnvironment: {‘auto’ ‘auto’ ‘auto’ ‘auto’}

As you can see, there are four outputs for the minibatch, which appears to contradict the original error message that there are only two minibatchqueue outputs
Also to confirm, i double checked the transformer input output structure:
net

net =

dlnetwork with properties:

Layers: [64×1 nnet.cnn.layer.Layer]
Connections: [1714×2 table]
Learnables: [110×3 table]
State: [0×3 table]
InputNames: {‘in_enc’ ‘in_dec’}
OutputNames: {‘decoder_out’ ‘fc_13’}
Initialized: 1

View summary with summary.
which shows two inputs and two outputs.
Could someone point me to the mistake I’m making here (likely with the datastore format) – it seems that during batching, the model is only choosing two of the cell columns from cell_data/dstrain for the input and output, rather than all four and its not clear why…thanks in advance for your help!
CGThe full error message reads "Error using trainnet (line 46)
The number of mini-batch queue outputs (2) must match the number of network inputs plus
the number of network outputs (4)."
I’m using an arrayDatastore to pass the predictors (x2) and the targets(x2) to the transformer model. Both predictors have 410 features, one of the targets has 410 features and the other target is a scalar function.
Code to generate the dummy predictor and target data is pasted below:
%——————————————————————–
% data generation for encoder
numObs = 10;
seqLen = vocabSize;
x_enc = randi([1,10],[seqLen,numObs]);
y_enc = zeros(numObs,1);
for i = 1:numObs
idx = x_enc(1:2,i);
y_enc(i,:) = sum(x_enc(idx,i));
end
x_enc = num2cell(x_enc’,2);
y_enc = num2cell(y_enc)’;
x_1 = x_enc;
y_2 = y_enc’;
% data generation for decoder
x_series = randi([1,10],[seqLen,numObs]);
y_series = sin(rand([seqLen,numObs]));
x_dec = x_series(:,1:end)’;
y_dec = y_series(:,1:end)’;
x_dec = num2cell(x_dec,2); x_2 = x_dec;
y_dec = num2cell(y_dec,2); y_1 = y_dec;
cell_data = {}; cell_data = [cell_data x_1 x_2 y_1 y_2];
dstrain = arrayDatastore(cell_data,’OutputType’,’same’);
%——————————————————————-
cell_data is of the form:
cell_data

cell_data =

10×4 cell array

{1×410 double} {1×410 double} {1×410 double} {[ 8]}
{1×410 double} {1×410 double} {1×410 double} {[10]}
{1×410 double} {1×410 double} {1×410 double} {[13]}
{1×410 double} {1×410 double} {1×410 double} {[20]}
{1×410 double} {1×410 double} {1×410 double} {[ 7]}
{1×410 double} {1×410 double} {1×410 double} {[ 8]}
{1×410 double} {1×410 double} {1×410 double} {[17]}
{1×410 double} {1×410 double} {1×410 double} {[ 6]}
{1×410 double} {1×410 double} {1×410 double} {[11]}
{1×410 double} {1×410 double} {1×410 double} {[ 8]}

If I were to use readall(dstrain) to read the datastore, I get the same format as cell_data:
fds = readall(dstrain)

fds =

10×4 cell array

{1×410 double} {1×410 double} {1×410 double} {[ 8]}
{1×410 double} {1×410 double} {1×410 double} {[10]}
{1×410 double} {1×410 double} {1×410 double} {[13]}
{1×410 double} {1×410 double} {1×410 double} {[20]}
{1×410 double} {1×410 double} {1×410 double} {[ 7]}
{1×410 double} {1×410 double} {1×410 double} {[ 8]}
{1×410 double} {1×410 double} {1×410 double} {[17]}
{1×410 double} {1×410 double} {1×410 double} {[ 6]}
{1×410 double} {1×410 double} {1×410 double} {[11]}
{1×410 double} {1×410 double} {1×410 double} {[ 8]}

Finally, if I use minibatchqueue to create a minibatch of datastore ‘dstrain’, I get:
mbq = minibatchqueue(dstrain)

mbq =

minibatchqueue with 4 outputs and properties:

Mini-batch creation:
MiniBatchSize: 10
PartialMiniBatch: ‘return’
MiniBatchFcn: ‘collate’
PreprocessingEnvironment: ‘serial’

Outputs:
OutputCast: {‘single’ ‘single’ ‘single’ ‘single’}
OutputAsDlarray: [1 1 1 1]
MiniBatchFormat: {” ” ” ”}
OutputEnvironment: {‘auto’ ‘auto’ ‘auto’ ‘auto’}

As you can see, there are four outputs for the minibatch, which appears to contradict the original error message that there are only two minibatchqueue outputs
Also to confirm, i double checked the transformer input output structure:
net

net =

dlnetwork with properties:

Layers: [64×1 nnet.cnn.layer.Layer]
Connections: [1714×2 table]
Learnables: [110×3 table]
State: [0×3 table]
InputNames: {‘in_enc’ ‘in_dec’}
OutputNames: {‘decoder_out’ ‘fc_13’}
Initialized: 1

View summary with summary.
which shows two inputs and two outputs.
Could someone point me to the mistake I’m making here (likely with the datastore format) – it seems that during batching, the model is only choosing two of the cell columns from cell_data/dstrain for the input and output, rather than all four and its not clear why…thanks in advance for your help!
CG The full error message reads "Error using trainnet (line 46)
The number of mini-batch queue outputs (2) must match the number of network inputs plus
the number of network outputs (4)."
I’m using an arrayDatastore to pass the predictors (x2) and the targets(x2) to the transformer model. Both predictors have 410 features, one of the targets has 410 features and the other target is a scalar function.
Code to generate the dummy predictor and target data is pasted below:
%——————————————————————–
% data generation for encoder
numObs = 10;
seqLen = vocabSize;
x_enc = randi([1,10],[seqLen,numObs]);
y_enc = zeros(numObs,1);
for i = 1:numObs
idx = x_enc(1:2,i);
y_enc(i,:) = sum(x_enc(idx,i));
end
x_enc = num2cell(x_enc’,2);
y_enc = num2cell(y_enc)’;
x_1 = x_enc;
y_2 = y_enc’;
% data generation for decoder
x_series = randi([1,10],[seqLen,numObs]);
y_series = sin(rand([seqLen,numObs]));
x_dec = x_series(:,1:end)’;
y_dec = y_series(:,1:end)’;
x_dec = num2cell(x_dec,2); x_2 = x_dec;
y_dec = num2cell(y_dec,2); y_1 = y_dec;
cell_data = {}; cell_data = [cell_data x_1 x_2 y_1 y_2];
dstrain = arrayDatastore(cell_data,’OutputType’,’same’);
%——————————————————————-
cell_data is of the form:
cell_data

cell_data =

10×4 cell array

{1×410 double} {1×410 double} {1×410 double} {[ 8]}
{1×410 double} {1×410 double} {1×410 double} {[10]}
{1×410 double} {1×410 double} {1×410 double} {[13]}
{1×410 double} {1×410 double} {1×410 double} {[20]}
{1×410 double} {1×410 double} {1×410 double} {[ 7]}
{1×410 double} {1×410 double} {1×410 double} {[ 8]}
{1×410 double} {1×410 double} {1×410 double} {[17]}
{1×410 double} {1×410 double} {1×410 double} {[ 6]}
{1×410 double} {1×410 double} {1×410 double} {[11]}
{1×410 double} {1×410 double} {1×410 double} {[ 8]}

If I were to use readall(dstrain) to read the datastore, I get the same format as cell_data:
fds = readall(dstrain)

fds =

10×4 cell array

{1×410 double} {1×410 double} {1×410 double} {[ 8]}
{1×410 double} {1×410 double} {1×410 double} {[10]}
{1×410 double} {1×410 double} {1×410 double} {[13]}
{1×410 double} {1×410 double} {1×410 double} {[20]}
{1×410 double} {1×410 double} {1×410 double} {[ 7]}
{1×410 double} {1×410 double} {1×410 double} {[ 8]}
{1×410 double} {1×410 double} {1×410 double} {[17]}
{1×410 double} {1×410 double} {1×410 double} {[ 6]}
{1×410 double} {1×410 double} {1×410 double} {[11]}
{1×410 double} {1×410 double} {1×410 double} {[ 8]}

Finally, if I use minibatchqueue to create a minibatch of datastore ‘dstrain’, I get:
mbq = minibatchqueue(dstrain)

mbq =

minibatchqueue with 4 outputs and properties:

Mini-batch creation:
MiniBatchSize: 10
PartialMiniBatch: ‘return’
MiniBatchFcn: ‘collate’
PreprocessingEnvironment: ‘serial’

Outputs:
OutputCast: {‘single’ ‘single’ ‘single’ ‘single’}
OutputAsDlarray: [1 1 1 1]
MiniBatchFormat: {” ” ” ”}
OutputEnvironment: {‘auto’ ‘auto’ ‘auto’ ‘auto’}

As you can see, there are four outputs for the minibatch, which appears to contradict the original error message that there are only two minibatchqueue outputs
Also to confirm, i double checked the transformer input output structure:
net

net =

dlnetwork with properties:

Layers: [64×1 nnet.cnn.layer.Layer]
Connections: [1714×2 table]
Learnables: [110×3 table]
State: [0×3 table]
InputNames: {‘in_enc’ ‘in_dec’}
OutputNames: {‘decoder_out’ ‘fc_13’}
Initialized: 1

View summary with summary.
which shows two inputs and two outputs.
Could someone point me to the mistake I’m making here (likely with the datastore format) – it seems that during batching, the model is only choosing two of the cell columns from cell_data/dstrain for the input and output, rather than all four and its not clear why…thanks in advance for your help!
CG deep learning, minibatch, datastore MATLAB Answers — New Questions

​

License manager causing more errors. So just making it test
Matlab

License manager causing more errors. So just making it test

/ 2025-01-08

Test to runTest to run Test to run cocktail party problem, blind source separation, independent components analysis, bss, ica, test MATLAB Answers — New Questions

​

Can I ‘initialize’ a handle object in such a way that isvalid(object) would return false?
Matlab

Can I ‘initialize’ a handle object in such a way that isvalid(object) would return false?

/ 2025-01-08

I’m trying to initialize a variable (MyHandle) that I want to be a handle pointing to some object but which can’t currently be assigned to said object. I have code that needs to behave differently depending on if MyHandle is assigned or not yet and I haven’t found a good way to test if MyHandle has been assigned to a valid object or not.
The function ‘isvalid’ seems like the right choice to test this, however, isvalid throws the error "Incorrect number or types of inputs or outputs for function isvalid." when run on MyHandle in its unassigned state. I’ve tried different ways to initialize it like "handle([])" and "[]", but they all return that same error.
I’ve found some bandaid solutions like initializing MyHandle to an instance of some arbitrary handle subclass and then deleting that initialized object, or assigning MyHandle to be a value of type double and then using "isnumeric" as my test function instead of "isvalid," but I was wondering if there is a more "correct" way to do it for the sake of best practices.
Below is a sample class that recreates the behavior described above. To restate my question in terms of the class below: Is there an initialization for MyHandle I can use in the properties block that will allow IsHandleAssigned to return false before the first time AssignHandle is run with a valid handle and return true afterwards? OR is there a different function besides isvalid that I should be using in IsHandleAssigned to achieve that behavior?
classdef ExampleClass < handle
properties
MyHandle %Will be a handle pointing to an object of an arbitrary class
% MyHandle = handle([]) < This initialization returns an error
% MyHandle = [] < This initialization returns an error
% MyHandle = 0 < This works if I replace ‘isvalid’ with ‘isnumeric’
% but that seems like poor practice to do since it obfuscates the
% purpose of MyHandle
end

methods
function obj = AssignHandle(obj,handleIn)
%This method assigns the handle of whatever class it happens to
%be to my property.
obj.MyHandle = handleIn;
end
function HandleIsAssigned = IsHandleAssigned(obj)
%This method tests whether or not my handle was assigned. Is
%there a better function than isvalid to use?
HandleIsAssigned = isvalid(obj.MyHandle);
end
end
endI’m trying to initialize a variable (MyHandle) that I want to be a handle pointing to some object but which can’t currently be assigned to said object. I have code that needs to behave differently depending on if MyHandle is assigned or not yet and I haven’t found a good way to test if MyHandle has been assigned to a valid object or not.
The function ‘isvalid’ seems like the right choice to test this, however, isvalid throws the error "Incorrect number or types of inputs or outputs for function isvalid." when run on MyHandle in its unassigned state. I’ve tried different ways to initialize it like "handle([])" and "[]", but they all return that same error.
I’ve found some bandaid solutions like initializing MyHandle to an instance of some arbitrary handle subclass and then deleting that initialized object, or assigning MyHandle to be a value of type double and then using "isnumeric" as my test function instead of "isvalid," but I was wondering if there is a more "correct" way to do it for the sake of best practices.
Below is a sample class that recreates the behavior described above. To restate my question in terms of the class below: Is there an initialization for MyHandle I can use in the properties block that will allow IsHandleAssigned to return false before the first time AssignHandle is run with a valid handle and return true afterwards? OR is there a different function besides isvalid that I should be using in IsHandleAssigned to achieve that behavior?
classdef ExampleClass < handle
properties
MyHandle %Will be a handle pointing to an object of an arbitrary class
% MyHandle = handle([]) < This initialization returns an error
% MyHandle = [] < This initialization returns an error
% MyHandle = 0 < This works if I replace ‘isvalid’ with ‘isnumeric’
% but that seems like poor practice to do since it obfuscates the
% purpose of MyHandle
end

methods
function obj = AssignHandle(obj,handleIn)
%This method assigns the handle of whatever class it happens to
%be to my property.
obj.MyHandle = handleIn;
end
function HandleIsAssigned = IsHandleAssigned(obj)
%This method tests whether or not my handle was assigned. Is
%there a better function than isvalid to use?
HandleIsAssigned = isvalid(obj.MyHandle);
end
end
end I’m trying to initialize a variable (MyHandle) that I want to be a handle pointing to some object but which can’t currently be assigned to said object. I have code that needs to behave differently depending on if MyHandle is assigned or not yet and I haven’t found a good way to test if MyHandle has been assigned to a valid object or not.
The function ‘isvalid’ seems like the right choice to test this, however, isvalid throws the error "Incorrect number or types of inputs or outputs for function isvalid." when run on MyHandle in its unassigned state. I’ve tried different ways to initialize it like "handle([])" and "[]", but they all return that same error.
I’ve found some bandaid solutions like initializing MyHandle to an instance of some arbitrary handle subclass and then deleting that initialized object, or assigning MyHandle to be a value of type double and then using "isnumeric" as my test function instead of "isvalid," but I was wondering if there is a more "correct" way to do it for the sake of best practices.
Below is a sample class that recreates the behavior described above. To restate my question in terms of the class below: Is there an initialization for MyHandle I can use in the properties block that will allow IsHandleAssigned to return false before the first time AssignHandle is run with a valid handle and return true afterwards? OR is there a different function besides isvalid that I should be using in IsHandleAssigned to achieve that behavior?
classdef ExampleClass < handle
properties
MyHandle %Will be a handle pointing to an object of an arbitrary class
% MyHandle = handle([]) < This initialization returns an error
% MyHandle = [] < This initialization returns an error
% MyHandle = 0 < This works if I replace ‘isvalid’ with ‘isnumeric’
% but that seems like poor practice to do since it obfuscates the
% purpose of MyHandle
end

methods
function obj = AssignHandle(obj,handleIn)
%This method assigns the handle of whatever class it happens to
%be to my property.
obj.MyHandle = handleIn;
end
function HandleIsAssigned = IsHandleAssigned(obj)
%This method tests whether or not my handle was assigned. Is
%there a better function than isvalid to use?
HandleIsAssigned = isvalid(obj.MyHandle);
end
end
end handles MATLAB Answers — New Questions

​

getting group delay by differentiating phase of reflectance
Matlab

getting group delay by differentiating phase of reflectance

/ 2025-01-08

Hi all
I am trying to calculate and draw the group delay of contradirectional bragg grating.
I already calculated the reflectance and got its phase as shown in the figure.
when I differentiate the phase i got unlogical spikes like that figure

while the correct plot is shown in Yariv book as the following figure (trace denoted by taw)
to differentiate i tried two functions diff and gradient and both gave me the same spikes (which is wrong). These are the lines i used in matlab:
Reflection=S11;
R=abs(Reflection).^2;
R_phase2=unwrap(angle(Reflection));
phase_lambda=lambda*1e9;
dphasedlambda1 =-phase_lambda.^2./(2*pi*c).*( gradient(R_phase2) ./ gradient(phase_lambda));
dphasedlambda2 =-phase_lambda(1:end-1).^2./(2*pi*c).*( diff(R_phase2) ./ diff(phase_lambda));
Any help with that problemHi all
I am trying to calculate and draw the group delay of contradirectional bragg grating.
I already calculated the reflectance and got its phase as shown in the figure.
when I differentiate the phase i got unlogical spikes like that figure

while the correct plot is shown in Yariv book as the following figure (trace denoted by taw)
to differentiate i tried two functions diff and gradient and both gave me the same spikes (which is wrong). These are the lines i used in matlab:
Reflection=S11;
R=abs(Reflection).^2;
R_phase2=unwrap(angle(Reflection));
phase_lambda=lambda*1e9;
dphasedlambda1 =-phase_lambda.^2./(2*pi*c).*( gradient(R_phase2) ./ gradient(phase_lambda));
dphasedlambda2 =-phase_lambda(1:end-1).^2./(2*pi*c).*( diff(R_phase2) ./ diff(phase_lambda));
Any help with that problem Hi all
I am trying to calculate and draw the group delay of contradirectional bragg grating.
I already calculated the reflectance and got its phase as shown in the figure.
when I differentiate the phase i got unlogical spikes like that figure

while the correct plot is shown in Yariv book as the following figure (trace denoted by taw)
to differentiate i tried two functions diff and gradient and both gave me the same spikes (which is wrong). These are the lines i used in matlab:
Reflection=S11;
R=abs(Reflection).^2;
R_phase2=unwrap(angle(Reflection));
phase_lambda=lambda*1e9;
dphasedlambda1 =-phase_lambda.^2./(2*pi*c).*( gradient(R_phase2) ./ gradient(phase_lambda));
dphasedlambda2 =-phase_lambda(1:end-1).^2./(2*pi*c).*( diff(R_phase2) ./ diff(phase_lambda));
Any help with that problem group delay, bragg, phase differentiation MATLAB Answers — New Questions

​

Dual fuel engine model
Matlab

Dual fuel engine model

/ 2025-01-08

Is there some sort of dual fuel engine model already accessible? If not, are there any sort of forums or videos i could use as help to build Such a model. My simulink skills are very basic at the moment.Is there some sort of dual fuel engine model already accessible? If not, are there any sort of forums or videos i could use as help to build Such a model. My simulink skills are very basic at the moment. Is there some sort of dual fuel engine model already accessible? If not, are there any sort of forums or videos i could use as help to build Such a model. My simulink skills are very basic at the moment. dual fuel, lpg, engine MATLAB Answers — New Questions

​

Generate signal according to the the rising edges of two pulse generators in simulink.
Matlab

Generate signal according to the the rising edges of two pulse generators in simulink.

/ 2025-01-08

Assume there are two pulses A and B with arbitrary periods and pulse widths.
I want to use existing popular blocks(without MATLAB Function) to realize such functionality–
it sets the output as 1 at the rising edge of A if B=0 and resets the output to 0 at the rising edge of B.
I have been thinking for a whole day without a good solution.
Anyone please help me on that.Assume there are two pulses A and B with arbitrary periods and pulse widths.
I want to use existing popular blocks(without MATLAB Function) to realize such functionality–
it sets the output as 1 at the rising edge of A if B=0 and resets the output to 0 at the rising edge of B.
I have been thinking for a whole day without a good solution.
Anyone please help me on that. Assume there are two pulses A and B with arbitrary periods and pulse widths.
I want to use existing popular blocks(without MATLAB Function) to realize such functionality–
it sets the output as 1 at the rising edge of A if B=0 and resets the output to 0 at the rising edge of B.
I have been thinking for a whole day without a good solution.
Anyone please help me on that. signal processing MATLAB Answers — New Questions

​

Previous 1 … 93 94 95 96 97 … 101 Next

Search

Categories

  • Matlab
  • Microsoft
  • News
  • Other
Application Package Repository Telkom University

Tags

matlab microsoft opensources
Application Package Download License

Application Package Download License

Adobe
Google for Education
IBM
Matlab
Microsoft
Wordpress
Visual Paradigm
Opensource

Sign Up For Newsletters

Be the First to Know. Sign up for newsletter today

Application Package Repository Telkom University

Portal Application Package Repository Telkom University, for internal use only, empower civitas academica in study and research.

Information

  • Telkom University
  • About Us
  • Contact
  • Forum Discussion
  • FAQ
  • Helpdesk Ticket

Contact Us

  • Ask: Any question please read FAQ
  • Mail: helpdesk@telkomuniversity.ac.id
  • Call: +62 823-1994-9941
  • WA: +62 823-1994-9943
  • Site: Gedung Panambulai. Jl. Telekomunikasi

Copyright © Telkom University. All Rights Reserved. ch

  • FAQ
  • Privacy Policy
  • Term

This Application Package for internal Telkom University only (students and employee). Chiers... Dismiss