Tag Archives: matlab
Generating an unknown ammount of Buttons in App Designer
Hello,
I’m trying to generate Buttons programmatically with the App Designer.
I have an Excel File, where all the names of the Buttons are listet, not knowing how many Buttons (or lines in Excel) will be needed.
I figured out how to create components with the App Designer programmtically:
https://de.mathworks.com/help/matlab/creating_guis/add-ui-components-to-app-designer-programmatically.html
So I tried many things, but none of them worked.
The problem is, that (as far as I understood) every Button (or other element) in the GUI needs his own variable. So I have to create new variables with the function eval, wich is, how I found out on every site here, absoulutly forbidden…
My first thought was to create an Array, but it didn’t work:
Unable to perform assignment because dot indexing is not supported for variables of this type.
And heres the Code:
A = [378 700 100 22]; %Position of the Button
allKeys = string(keys(CellContOne)); %allKeys gets all the Buttonnames as a String
UniButton = zeros(length(allKeys)); %An Array with the length of the List is created
for i = 1:length(allKeys) %For Loop to create the Buttons
UniButton(i) = uibutton(app.UIFigure, ‘state’); %Creating a Button
UniButton(i).Position = A; %Giving the Button a position
UniButton(i).Text = allKeys(i); %Giving the Button it’s Text
b_text = UniButton(i).Text; %global Variable gets the Text
b_value = UniButton(i).Value; %global Variable gets the Value
UniButton(i).ValueChangedFcn = @app.mybuttonpress; %Callback function
A(2) = A(2) -25; %Position change for the next Button
end
I also tried using just one variable for every Button, but it didn’t work because the GUI wasn’t able to figure out wich button was pressed (I need this information for the callback) The code looks the same, just without the index (i) and the line UniButton = zeros(length(allKeys));
Structures and Cell Arrays also didn’t work for me.
I hope You can help me!Hello,
I’m trying to generate Buttons programmatically with the App Designer.
I have an Excel File, where all the names of the Buttons are listet, not knowing how many Buttons (or lines in Excel) will be needed.
I figured out how to create components with the App Designer programmtically:
https://de.mathworks.com/help/matlab/creating_guis/add-ui-components-to-app-designer-programmatically.html
So I tried many things, but none of them worked.
The problem is, that (as far as I understood) every Button (or other element) in the GUI needs his own variable. So I have to create new variables with the function eval, wich is, how I found out on every site here, absoulutly forbidden…
My first thought was to create an Array, but it didn’t work:
Unable to perform assignment because dot indexing is not supported for variables of this type.
And heres the Code:
A = [378 700 100 22]; %Position of the Button
allKeys = string(keys(CellContOne)); %allKeys gets all the Buttonnames as a String
UniButton = zeros(length(allKeys)); %An Array with the length of the List is created
for i = 1:length(allKeys) %For Loop to create the Buttons
UniButton(i) = uibutton(app.UIFigure, ‘state’); %Creating a Button
UniButton(i).Position = A; %Giving the Button a position
UniButton(i).Text = allKeys(i); %Giving the Button it’s Text
b_text = UniButton(i).Text; %global Variable gets the Text
b_value = UniButton(i).Value; %global Variable gets the Value
UniButton(i).ValueChangedFcn = @app.mybuttonpress; %Callback function
A(2) = A(2) -25; %Position change for the next Button
end
I also tried using just one variable for every Button, but it didn’t work because the GUI wasn’t able to figure out wich button was pressed (I need this information for the callback) The code looks the same, just without the index (i) and the line UniButton = zeros(length(allKeys));
Structures and Cell Arrays also didn’t work for me.
I hope You can help me! Hello,
I’m trying to generate Buttons programmatically with the App Designer.
I have an Excel File, where all the names of the Buttons are listet, not knowing how many Buttons (or lines in Excel) will be needed.
I figured out how to create components with the App Designer programmtically:
https://de.mathworks.com/help/matlab/creating_guis/add-ui-components-to-app-designer-programmatically.html
So I tried many things, but none of them worked.
The problem is, that (as far as I understood) every Button (or other element) in the GUI needs his own variable. So I have to create new variables with the function eval, wich is, how I found out on every site here, absoulutly forbidden…
My first thought was to create an Array, but it didn’t work:
Unable to perform assignment because dot indexing is not supported for variables of this type.
And heres the Code:
A = [378 700 100 22]; %Position of the Button
allKeys = string(keys(CellContOne)); %allKeys gets all the Buttonnames as a String
UniButton = zeros(length(allKeys)); %An Array with the length of the List is created
for i = 1:length(allKeys) %For Loop to create the Buttons
UniButton(i) = uibutton(app.UIFigure, ‘state’); %Creating a Button
UniButton(i).Position = A; %Giving the Button a position
UniButton(i).Text = allKeys(i); %Giving the Button it’s Text
b_text = UniButton(i).Text; %global Variable gets the Text
b_value = UniButton(i).Value; %global Variable gets the Value
UniButton(i).ValueChangedFcn = @app.mybuttonpress; %Callback function
A(2) = A(2) -25; %Position change for the next Button
end
I also tried using just one variable for every Button, but it didn’t work because the GUI wasn’t able to figure out wich button was pressed (I need this information for the callback) The code looks the same, just without the index (i) and the line UniButton = zeros(length(allKeys));
Structures and Cell Arrays also didn’t work for me.
I hope You can help me! appdesigner MATLAB Answers — New Questions
Problem with the odt notation of “configureTerminator” for serialport
Hi,
I do this with serial port:
sss=serialport(‘com1’,9600)
Then, I try to configure the terminator with the dot notation:
sss.configureTerminator = ‘CR’
I receive this error:
Assignment not supported because the result of method ‘configureTerminator’ is a temporary value.
If I do this:
>> configureTerminator(sss,’cr’)
that works.
Why? I wrong something in the sintax?
All the other commnads I used like flush, write, writeline, read, etc have not shown problems with dot notation.
Tyhank you, Gianluigi
PS: This is my license:
—————————————————————————————————–
MATLAB Version: 24.1.0.2461801 (R2024a) Prerelease Update 1
MATLAB License Number: ••••••
Operating System: Microsoft Windows 10 Pro Version 10.0 (Build 19045)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
—————————————————————————————————–
MATLAB Version 24.1 (R2024a)
Simulink Version 24.1 (R2024a)
Curve Fitting Toolbox Version 24.1 (R2024a)
Data Acquisition Toolbox Version 24.1 (R2024a)
Database Toolbox Version 24.1 (R2024a)
Instrument Control Toolbox Version 24.1 (R2024a)
Optimization Toolbox Version 24.1 (R2024a)
Parallel Computing Toolbox Version 24.1 (R2024a)
Simscape Version 24.1 (R2024a)
Simscape Electrical Version 24.1 (R2024a)
Symbolic Math Toolbox Version 24.1 (R2024a)
System Composer Version 24.1 (R2024a)Hi,
I do this with serial port:
sss=serialport(‘com1’,9600)
Then, I try to configure the terminator with the dot notation:
sss.configureTerminator = ‘CR’
I receive this error:
Assignment not supported because the result of method ‘configureTerminator’ is a temporary value.
If I do this:
>> configureTerminator(sss,’cr’)
that works.
Why? I wrong something in the sintax?
All the other commnads I used like flush, write, writeline, read, etc have not shown problems with dot notation.
Tyhank you, Gianluigi
PS: This is my license:
—————————————————————————————————–
MATLAB Version: 24.1.0.2461801 (R2024a) Prerelease Update 1
MATLAB License Number: ••••••
Operating System: Microsoft Windows 10 Pro Version 10.0 (Build 19045)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
—————————————————————————————————–
MATLAB Version 24.1 (R2024a)
Simulink Version 24.1 (R2024a)
Curve Fitting Toolbox Version 24.1 (R2024a)
Data Acquisition Toolbox Version 24.1 (R2024a)
Database Toolbox Version 24.1 (R2024a)
Instrument Control Toolbox Version 24.1 (R2024a)
Optimization Toolbox Version 24.1 (R2024a)
Parallel Computing Toolbox Version 24.1 (R2024a)
Simscape Version 24.1 (R2024a)
Simscape Electrical Version 24.1 (R2024a)
Symbolic Math Toolbox Version 24.1 (R2024a)
System Composer Version 24.1 (R2024a) Hi,
I do this with serial port:
sss=serialport(‘com1’,9600)
Then, I try to configure the terminator with the dot notation:
sss.configureTerminator = ‘CR’
I receive this error:
Assignment not supported because the result of method ‘configureTerminator’ is a temporary value.
If I do this:
>> configureTerminator(sss,’cr’)
that works.
Why? I wrong something in the sintax?
All the other commnads I used like flush, write, writeline, read, etc have not shown problems with dot notation.
Tyhank you, Gianluigi
PS: This is my license:
—————————————————————————————————–
MATLAB Version: 24.1.0.2461801 (R2024a) Prerelease Update 1
MATLAB License Number: ••••••
Operating System: Microsoft Windows 10 Pro Version 10.0 (Build 19045)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
—————————————————————————————————–
MATLAB Version 24.1 (R2024a)
Simulink Version 24.1 (R2024a)
Curve Fitting Toolbox Version 24.1 (R2024a)
Data Acquisition Toolbox Version 24.1 (R2024a)
Database Toolbox Version 24.1 (R2024a)
Instrument Control Toolbox Version 24.1 (R2024a)
Optimization Toolbox Version 24.1 (R2024a)
Parallel Computing Toolbox Version 24.1 (R2024a)
Simscape Version 24.1 (R2024a)
Simscape Electrical Version 24.1 (R2024a)
Symbolic Math Toolbox Version 24.1 (R2024a)
System Composer Version 24.1 (R2024a) serialport, configureterminator MATLAB Answers — New Questions
Choose a random button from a set of 9 arranged in a 3×3?
app.FirstNumber.Text = num2str(app.First_Number);
app.SecondNumber.Text = num2str(app.Second_Number);
app.Operator.Text = "+";
Answer = app.First_Number + app.Second_Number; % Operator needs to be able to change
n = randi(9);
app.Button_(n).Text = num2str(Answer); % Button needs to move to a random button_(1-9)
Essentially im trying to make a random button become the correct answer, but i keep getting an error message of Button_ is not a recodnized method or property.app.FirstNumber.Text = num2str(app.First_Number);
app.SecondNumber.Text = num2str(app.Second_Number);
app.Operator.Text = "+";
Answer = app.First_Number + app.Second_Number; % Operator needs to be able to change
n = randi(9);
app.Button_(n).Text = num2str(Answer); % Button needs to move to a random button_(1-9)
Essentially im trying to make a random button become the correct answer, but i keep getting an error message of Button_ is not a recodnized method or property. app.FirstNumber.Text = num2str(app.First_Number);
app.SecondNumber.Text = num2str(app.Second_Number);
app.Operator.Text = "+";
Answer = app.First_Number + app.Second_Number; % Operator needs to be able to change
n = randi(9);
app.Button_(n).Text = num2str(Answer); % Button needs to move to a random button_(1-9)
Essentially im trying to make a random button become the correct answer, but i keep getting an error message of Button_ is not a recodnized method or property. button, error MATLAB Answers — New Questions
Add-on Explorer shows a blank window
When I open the Add-on Explorer, it only shows a blank window. But if I move around the cursor, it does change its look (from ‘Normal Select’ to ‘Link Select’, as the picture shows) at some places.
<</matlabcentral/answers/uploaded_files/120430/problem.png>>
Besides, Add-on Manager shows the same problem, while the ‘Package App’ window works fine.
I tried reinstall MATLAB, but the problem remained.
(I’m using MATLAB R2018a on Windows 10 64-bit)
Recently I used an extended monitor, and I wonder if that’s the cause of the problem.
In case there is no solution, can I install a .mlpkginstall file manually?When I open the Add-on Explorer, it only shows a blank window. But if I move around the cursor, it does change its look (from ‘Normal Select’ to ‘Link Select’, as the picture shows) at some places.
<</matlabcentral/answers/uploaded_files/120430/problem.png>>
Besides, Add-on Manager shows the same problem, while the ‘Package App’ window works fine.
I tried reinstall MATLAB, but the problem remained.
(I’m using MATLAB R2018a on Windows 10 64-bit)
Recently I used an extended monitor, and I wonder if that’s the cause of the problem.
In case there is no solution, can I install a .mlpkginstall file manually? When I open the Add-on Explorer, it only shows a blank window. But if I move around the cursor, it does change its look (from ‘Normal Select’ to ‘Link Select’, as the picture shows) at some places.
<</matlabcentral/answers/uploaded_files/120430/problem.png>>
Besides, Add-on Manager shows the same problem, while the ‘Package App’ window works fine.
I tried reinstall MATLAB, but the problem remained.
(I’m using MATLAB R2018a on Windows 10 64-bit)
Recently I used an extended monitor, and I wonder if that’s the cause of the problem.
In case there is no solution, can I install a .mlpkginstall file manually? add-on explorer, add-on manager, blank window MATLAB Answers — New Questions
Why are my error bars multicoloured with no line?
When I run this very simple code the graph plotted has multicoloured error bars and no joining line? Why.
figure(24)
x = 20:1:25;
y = [1.75 1.78 1.81 1.85 1.9 1.95];
err = 0.1;
errorbar(x,y,err)When I run this very simple code the graph plotted has multicoloured error bars and no joining line? Why.
figure(24)
x = 20:1:25;
y = [1.75 1.78 1.81 1.85 1.9 1.95];
err = 0.1;
errorbar(x,y,err) When I run this very simple code the graph plotted has multicoloured error bars and no joining line? Why.
figure(24)
x = 20:1:25;
y = [1.75 1.78 1.81 1.85 1.9 1.95];
err = 0.1;
errorbar(x,y,err) errorbar, graph, matlab MATLAB Answers — New Questions
How to modify the sltrace.Graph objects? I want to delete an element of the DstBlocks array
Hello dear Community,
I would like to delete a block from the DstBlock path. I am using sltrace function and the resulting sltrace.Graph is to be by the user modified. I have read that you have to use "set" and "get" methods because they are property values but I have not been succesful to modify anything. From Matlab help I see that set function can be used like this: set(object, property, value)
I am programming the following line to modify the Trace Path in this case I want to modify the Destination Blocks ( DstBlocks array):
test1 = sltrace(element, ‘Destination’, ‘TraceAll’,’on’);
set(test1.DstBlocks(1), "Value", [ ]);
I am trying here to delete/ modify the value of the first (1) object of the resulting array DstBlock of the resulting Trace Path (test1). What woudl be the correct function to use or the correct sintax if the function set is to be used? Thank you.Hello dear Community,
I would like to delete a block from the DstBlock path. I am using sltrace function and the resulting sltrace.Graph is to be by the user modified. I have read that you have to use "set" and "get" methods because they are property values but I have not been succesful to modify anything. From Matlab help I see that set function can be used like this: set(object, property, value)
I am programming the following line to modify the Trace Path in this case I want to modify the Destination Blocks ( DstBlocks array):
test1 = sltrace(element, ‘Destination’, ‘TraceAll’,’on’);
set(test1.DstBlocks(1), "Value", [ ]);
I am trying here to delete/ modify the value of the first (1) object of the resulting array DstBlock of the resulting Trace Path (test1). What woudl be the correct function to use or the correct sintax if the function set is to be used? Thank you. Hello dear Community,
I would like to delete a block from the DstBlock path. I am using sltrace function and the resulting sltrace.Graph is to be by the user modified. I have read that you have to use "set" and "get" methods because they are property values but I have not been succesful to modify anything. From Matlab help I see that set function can be used like this: set(object, property, value)
I am programming the following line to modify the Trace Path in this case I want to modify the Destination Blocks ( DstBlocks array):
test1 = sltrace(element, ‘Destination’, ‘TraceAll’,’on’);
set(test1.DstBlocks(1), "Value", [ ]);
I am trying here to delete/ modify the value of the first (1) object of the resulting array DstBlock of the resulting Trace Path (test1). What woudl be the correct function to use or the correct sintax if the function set is to be used? Thank you. sltrace, property values, set MATLAB Answers — New Questions
a nonlinear system and its control input in simulink
hi guys the system is as follows ;
which k(a,h) is defined as follows ;
I generally implement its block – daigram in simulink as follows ; I’m not sure whether it’s correct or not ; I need your help on defining the functionshi guys the system is as follows ;
which k(a,h) is defined as follows ;
I generally implement its block – daigram in simulink as follows ; I’m not sure whether it’s correct or not ; I need your help on defining the functions hi guys the system is as follows ;
which k(a,h) is defined as follows ;
I generally implement its block – daigram in simulink as follows ; I’m not sure whether it’s correct or not ; I need your help on defining the functions control MATLAB Answers — New Questions
Principal axis + phase and inclination.
Hello, I would appreciate any assistance in calculating the following variables:
Semi-major axis (Mayor), Semi-minor axis (Minor), Inclination and Phase
of Horizontal velocities u and v are represented as complex numbers complex(u,v) with the purpose of plotting the ellipse as shown in the attached figure.
%horizontal velocity ellipse rotating clockwise.Hello, I would appreciate any assistance in calculating the following variables:
Semi-major axis (Mayor), Semi-minor axis (Minor), Inclination and Phase
of Horizontal velocities u and v are represented as complex numbers complex(u,v) with the purpose of plotting the ellipse as shown in the attached figure.
%horizontal velocity ellipse rotating clockwise. Hello, I would appreciate any assistance in calculating the following variables:
Semi-major axis (Mayor), Semi-minor axis (Minor), Inclination and Phase
of Horizontal velocities u and v are represented as complex numbers complex(u,v) with the purpose of plotting the ellipse as shown in the attached figure.
%horizontal velocity ellipse rotating clockwise. matlab MATLAB Answers — New Questions
come salvare un pacchetto (entity in simevents) nel workspace di matlab?
I would like to create a block that receives a flow of packets (simevents entity) and saves all the packets that end up inside it together with the arrival time in the matlab workspace.
Possibly I would like the name of the variable in which the packet flow is saved to be configurable from the block mask in order to facilitate the creation of many of these blocks without going.
I already have a version that uses the ToWorkspace block but it doesn’t allow me to easily configure the name of the variable where packages end up, so I was wondering if there is a better solution.I would like to create a block that receives a flow of packets (simevents entity) and saves all the packets that end up inside it together with the arrival time in the matlab workspace.
Possibly I would like the name of the variable in which the packet flow is saved to be configurable from the block mask in order to facilitate the creation of many of these blocks without going.
I already have a version that uses the ToWorkspace block but it doesn’t allow me to easily configure the name of the variable where packages end up, so I was wondering if there is a better solution. I would like to create a block that receives a flow of packets (simevents entity) and saves all the packets that end up inside it together with the arrival time in the matlab workspace.
Possibly I would like the name of the variable in which the packet flow is saved to be configurable from the block mask in order to facilitate the creation of many of these blocks without going.
I already have a version that uses the ToWorkspace block but it doesn’t allow me to easily configure the name of the variable where packages end up, so I was wondering if there is a better solution. workspace MATLAB Answers — New Questions
SCI-TX doesnt work properly
I want to send the data calculated in my power electronics algorithm to serial port to log the data. Hovewer, I am very confused on how to correctly route the signals to SCI-TX block. Even this simple code wont send any proper data to UART. What am i doing wrong? Should i enable FIFO interrupts ? I even tried changing the Output X-BAR configurations. More interestingly, my original code works in LAUNCHXL-F280025C but not in my project card with the same mcu on it.I want to send the data calculated in my power electronics algorithm to serial port to log the data. Hovewer, I am very confused on how to correctly route the signals to SCI-TX block. Even this simple code wont send any proper data to UART. What am i doing wrong? Should i enable FIFO interrupts ? I even tried changing the Output X-BAR configurations. More interestingly, my original code works in LAUNCHXL-F280025C but not in my project card with the same mcu on it. I want to send the data calculated in my power electronics algorithm to serial port to log the data. Hovewer, I am very confused on how to correctly route the signals to SCI-TX block. Even this simple code wont send any proper data to UART. What am i doing wrong? Should i enable FIFO interrupts ? I even tried changing the Output X-BAR configurations. More interestingly, my original code works in LAUNCHXL-F280025C but not in my project card with the same mcu on it. simulink, serial, code generation MATLAB Answers — New Questions
High Reprojection Error Discrepancy Between Kalibr and MATLAB Camera Calibration on Same Dataset estimateCameraIMUTransform function.
Hello everyone,
I’m encountering a puzzling issue while attempting to calibrate a camera and imu using MATLAB’s camera calibration toolbox. I’m using the same dataset that I successfully used with Kalibr, but I’m observing significantly higher reprojection errors in MATLAB compared to Kalibr.
Despite achieving very low reprojection errors when using the same dataset with Kalibr, I’m puzzled by the discrepancy when running the calibration in MATLAB. The extrinsics error in MATLAB is much higher than expected.
Has anyone else encountered a similar issue? I would greatly appreciate any insights or suggestions on how to address this discrepancy and improve the accuracy of the calibration in MATLAB.
Thank you in advance for your help!Hello everyone,
I’m encountering a puzzling issue while attempting to calibrate a camera and imu using MATLAB’s camera calibration toolbox. I’m using the same dataset that I successfully used with Kalibr, but I’m observing significantly higher reprojection errors in MATLAB compared to Kalibr.
Despite achieving very low reprojection errors when using the same dataset with Kalibr, I’m puzzled by the discrepancy when running the calibration in MATLAB. The extrinsics error in MATLAB is much higher than expected.
Has anyone else encountered a similar issue? I would greatly appreciate any insights or suggestions on how to address this discrepancy and improve the accuracy of the calibration in MATLAB.
Thank you in advance for your help! Hello everyone,
I’m encountering a puzzling issue while attempting to calibrate a camera and imu using MATLAB’s camera calibration toolbox. I’m using the same dataset that I successfully used with Kalibr, but I’m observing significantly higher reprojection errors in MATLAB compared to Kalibr.
Despite achieving very low reprojection errors when using the same dataset with Kalibr, I’m puzzled by the discrepancy when running the calibration in MATLAB. The extrinsics error in MATLAB is much higher than expected.
Has anyone else encountered a similar issue? I would greatly appreciate any insights or suggestions on how to address this discrepancy and improve the accuracy of the calibration in MATLAB.
Thank you in advance for your help! imu, camera, inertial, calibration MATLAB Answers — New Questions
is there any reason for this?
In Matlab
"1" + "1" = "11"
but
‘1’ + ‘1’ = 98
i.e.
char(49) = ‘1’
but
char(49) + char(49) = 98
Is there any reason for this convention?In Matlab
"1" + "1" = "11"
but
‘1’ + ‘1’ = 98
i.e.
char(49) = ‘1’
but
char(49) + char(49) = 98
Is there any reason for this convention? In Matlab
"1" + "1" = "11"
but
‘1’ + ‘1’ = 98
i.e.
char(49) = ‘1’
but
char(49) + char(49) = 98
Is there any reason for this convention? mathematics MATLAB Answers — New Questions
PSD of DWT details coefficnet
Hi,
I am working on a project involves sensor data analysis. I have a data for entire year that is sampled every 15 minutes. I used DWT (db4 up to three levels) to analyze the high-frequency content of the main signal.
After applying PSD on the reconstructed details signal, I can see some patterns between the levels, which I don’t have a good explanations for them. According to the attached figure, level 3 has two cycles, level 2 one cycle, and level one half cycle. Why is that?
Also, as I remember DWT isolate frequency bands per each level, while there are some overlap in frequencies here. Is it due to the filter nature?
I really appreciate if you can give me your thoughts or suggestions.
Thank you in advance.Hi,
I am working on a project involves sensor data analysis. I have a data for entire year that is sampled every 15 minutes. I used DWT (db4 up to three levels) to analyze the high-frequency content of the main signal.
After applying PSD on the reconstructed details signal, I can see some patterns between the levels, which I don’t have a good explanations for them. According to the attached figure, level 3 has two cycles, level 2 one cycle, and level one half cycle. Why is that?
Also, as I remember DWT isolate frequency bands per each level, while there are some overlap in frequencies here. Is it due to the filter nature?
I really appreciate if you can give me your thoughts or suggestions.
Thank you in advance. Hi,
I am working on a project involves sensor data analysis. I have a data for entire year that is sampled every 15 minutes. I used DWT (db4 up to three levels) to analyze the high-frequency content of the main signal.
After applying PSD on the reconstructed details signal, I can see some patterns between the levels, which I don’t have a good explanations for them. According to the attached figure, level 3 has two cycles, level 2 one cycle, and level one half cycle. Why is that?
Also, as I remember DWT isolate frequency bands per each level, while there are some overlap in frequencies here. Is it due to the filter nature?
I really appreciate if you can give me your thoughts or suggestions.
Thank you in advance. dwt, wavelet, frequency_analysis, digital signal processing MATLAB Answers — New Questions
How to sort table more than one variable with specified condition ?
hi guys, can u tell me a different way to sort table by 2 variable columns which more simple than my method?
I want to sort jointTOS by its X and Z from minimum to maximum but X is the priority.
Here the code :
clear;
clc;
H = 5;
L = 15;
Ns = 2;
Nb = 1;
PortalHeight = H;
Bayspan = L;
NumberStory = Ns;
NumberBay = Nb;
% Variable1
h = [0.8,1.00,1.20,1.40,1.6,1.80];
% Variable2
Lss = [2.00,2.40,2.80,3.20,3.60,4.00];
% Variable3
Nss = [2,3,4];
% Definition
Var1HeightofTrussBeam = h;
Var2LengthSpecialSegment = Lss;
Var3NumberSpecialSegment = Nss;
% % Xbase = zeros(1,length(Totalvariant));
% % Zbase = zeros(1,length(Totalvariant));
% % Xcol = zeros(1,length(Totalvariant));
% % Zcol = zeros(1,length(Totalvariant));
% % Xos = zeros(1,length(Totalvariant));
% % Zos = zeros(1,length(Totalvariant));
% % Xss = zeros(1,length(Totalvariant));
% % Zss = zeros(1,length(Totalvariant));
% % X = zeros(1,length(Totalvariant));
% % Z = zeros(1,length(Totalvariant));
% % jointbase = zeros(1,length(Totalvariant));
% % jointcolumn = zeros(1,length(Totalvariant));
% % jointordinarysegment = zeros(1,length(Totalvariant));
% % jointtopordinarysegment = zeros(1,length(Totalvariant));
% % jointbottomordinarysegment = zeros(1,length(Totalvariant));
% % jointspecialsegment = zeros(1,length(Totalvariant));
% % jointtopspecialsegment = zeros(1,length(Totalvariant));
% % jointbottomspecialsegment = zeros(1,length(Totalvariant));
ijk = 0;
for i = 1:numel(h)
for j = 1:numel(Lss)
for k = 1:numel(Nss)
ijk = ijk+1;
Variantmodel{ijk,:} = table(ijk,h(i),Lss(j),Nss(k),’VariableNames’,{‘VariantID’,’Height’,’Length’,’Number’});
%% Cooridinate Point Base(base)
Xbase{ijk,:} = L*(0:NumberBay);
Zbase{ijk,:} = repelem(0,1,length(Xbase{ijk,:}));
%% Column(col)
Xcolumn = L*(0:NumberBay);
Zcolumn = repelem(H*(1:NumberStory),1,length(Xcolumn));
Xbotbeam = L*(0:NumberBay);
Zbotbeam = repelem((H*(1:NumberStory)-h(i)),1,length(Xbotbeam));
% replicate [X] to be the same size as [Z] for plotting:
Xcol{ijk,:} = repmat([Xcolumn,Xbotbeam],1,NumberStory);
Zcol{ijk,:} = [Zcolumn,Zbotbeam];
%% Cooridinate Point Ordinary Segment (os)
% calculate span length of ordinary segment
Los = (L-Lss(j))/2;
Nos = Los/h(i);
Nos = round(Nos);
los = Los/Nos;
totalspan{ijk,:} = los*Nos*2+Lss(j);
if totalspan{ijk,:} == 15.000
checkspan{ijk,:} = "correct span";
else
checkspan{ijk,:} = "span must be 15m";
end
% top and bottom joint of ordinary segment(os)
XTopOrdinarySegment = reshape([los*(1:Nos),(L/2+Lss(j)/2)+los*(0:Nos-1)].’+L*(0:(NumberBay-1)),1,[]);
XBottomOrdinarySegment = XTopOrdinarySegment;
ZTopOrdinarySegment = repelem(H*(1:NumberStory),1,2*Nos*NumberBay);
ZBottomOrdinarySegment = repelem(H*(1:NumberStory)-h(i),1,2*Nos*NumberBay);
% replicate [X] to be the same size as [Z] for plotting:
Xos{ijk,:} = repmat([XTopOrdinarySegment,XBottomOrdinarySegment],1,NumberStory);
Zos{ijk,:} = [ZTopOrdinarySegment,ZBottomOrdinarySegment];
%% Cooridinate Point Special Segment (ss)
% calculate span length of special segment
lss = Lss(j)/Nss(k);
% top and bottom joint of special segment(ss)
XTopSpecialSegment = reshape((lss*(0:Nss(k))+L/2-Lss(j)/2).’+L*(0:(NumberBay-1)),1,[]);
XBottomSpecialSegment = XTopSpecialSegment;
ZTopSpecialSegment = repelem(H*(1:NumberStory),1,length(XTopSpecialSegment));
ZBottomSpecialSegment = repelem(H*(1:NumberStory)-h(i),1,length(XBottomSpecialSegment));
% replicate [X] to be the same size as [Z] for plotting:
Xss{ijk,:} = repmat([XTopSpecialSegment,XBottomSpecialSegment],1,NumberStory);
Zss{ijk,:} = [ZTopSpecialSegment,ZBottomSpecialSegment];
%% Plot Cooridinate Point (X,Z)
X{ijk,:} = [Xbase{ijk,:},Xcol{ijk,:},Xos{ijk,:},Xss{ijk,:}];
Z{ijk,:} = [Zbase{ijk,:},Zcol{ijk,:},Zos{ijk,:},Zss{ijk,:}];
scatter(X{ijk,:},Z{ijk,:},’filled’),grid on
%check angle
tangent = (Lss(j)/Nss(k))/h(i);
anglespecialsegment(ijk) = atand(tangent);
%% Name the Joint
jointbase{ijk} = table((1:numel(Xbase{ijk,:}))’,Xbase{ijk,:}’,Zbase{ijk,:}’,’VariableNames’,{‘ID’,’X’,’Z’});
jointcolumn{ijk} = table((max(jointbase{ijk}.ID)+1:numel(Xcol{ijk,:})+max(jointbase{ijk}.ID))’,Xcol{ijk,:}’,Zcol{ijk,:}’,’VariableNames’,{‘ID’,’X’,’Z’});
jointordinarysegment{ijk} = table((max(jointcolumn{ijk}.ID)+1:numel(Xos{ijk,:})+max(jointcolumn{ijk}.ID))’,Xos{ijk,:}’,Zos{ijk,:}’,’VariableNames’,{‘ID’,’X’,’Z’});
jointtopordinarysegment{ijk} = jointordinarysegment{ijk}(ismember(jointordinarysegment{ijk}.Z,Zcolumn),:);
jointbottomordinarysegment{ijk} = jointordinarysegment{ijk}(ismember(jointordinarysegment{ijk}.Z,Zbotbeam),:);
jointspecialsegment{ijk} = table((max(jointbottomordinarysegment{ijk}.ID)+1:numel(Xss{ijk,:})+max(jointbottomordinarysegment{ijk}.ID))’,Xss{ijk,:}’,Zss{ijk,:}’,’VariableNames’,{‘ID’,’X’,’Z’});
jointtopspecialsegment{ijk} = jointspecialsegment{ijk}(ismember(jointspecialsegment{ijk}.Z,Zcolumn),:);
jointbottomspecialsegment{ijk} = jointspecialsegment{ijk}(ismember(jointspecialsegment{ijk}.Z,Zbotbeam),:);
end
end
end
% Verify Variants Which Passed the Angle Requirement
tablecheck = table((1:numel(anglespecialsegment))’,totalspan,anglespecialsegment’,’VariableNames’,{‘VariantID’,’Total Span’,’Angle’});
VariantIDPassed = tablecheck.VariantID(tablecheck.Angle>=30 & tablecheck.Angle<=60);
jointbase = table((1:numel(jointbase))’,jointbase’,’VariableNames’,{‘VariantID’,’Joint Base’});
jointbase = jointbase(ismember(jointbase.VariantID,VariantIDPassed),:);
jointcolumn = table((1:numel(jointcolumn))’,jointcolumn’,’VariableNames’,{‘VariantID’,’Joint Column’});
jointcolumn = jointcolumn(ismember(jointcolumn.VariantID,VariantIDPassed),:);
jointtopordinarysegment = table((1:numel(jointtopordinarysegment))’,jointtopordinarysegment’,’VariableNames’,{‘VariantID’,’Joint Top Ordinary Segment’});
jointtopordinarysegment = jointtopordinarysegment(ismember(jointtopordinarysegment.VariantID,VariantIDPassed),:);
jointbottomordinarysegment = table((1:numel(jointbottomordinarysegment))’,jointbottomordinarysegment’,’VariableNames’,{‘VariantID’,’Joint Bottom Ordinary Segment’});
jointbottomordinarysegment = jointbottomordinarysegment(ismember(jointbottomordinarysegment.VariantID,VariantIDPassed),:);
jointtopspecialsegment = table((1:numel(jointtopspecialsegment))’,jointtopspecialsegment’,’VariableNames’,{‘VariantID’,’Joint Top Special Segment’});
jointtopspecialsegment = jointtopspecialsegment(ismember(jointtopspecialsegment.VariantID,VariantIDPassed),:);
jointbottomspecialsegment = table((1:numel(jointbottomspecialsegment))’,jointbottomspecialsegment’,’VariableNames’,{‘VariantID’,’Joint Bottom Special Segment’});
jointbottomspecialsegment = jointbottomspecialsegment(ismember(jointbottomspecialsegment.VariantID,VariantIDPassed),:);
%% Name the Frame
% column
for i = 1:height(VariantIDPassed)
jointIcolumn = 0;
jointJcolumn = 0;
jointcolumnnew{i,:} = jointcolumn.("Joint Column"){i}(ismember(jointcolumn.("Joint Column"){i}.Z,Zcolumn),:);
jointcolumnnew{i,:} = vertcat(jointbase.("Joint Base"){i},jointcolumnnew{i});
for j = 1:height(jointcolumnnew{i,1})-2
jointIcolumn(j) = jointcolumnnew{i,1}.ID(j);
jointJcolumn(j) = jointcolumnnew{i,1}.ID(j+2);
end
framecolumn{i,:} = table((1:j)’,jointIcolumn’,jointJcolumn’,’VariableNames’,{‘Frame ID’,’JointI’,’JoinJ’});
end
% top ordinary segment (TOS)
for i = 1:height(VariantIDPassed)
endTOS{i,:} = jointcolumn.("Joint Column"){i}(ismember(jointcolumn.("Joint Column"){i}.Z,Zcolumn),:);
jointTOS{i,:} = vertcat(jointtopordinarysegment.("Joint Top Ordinary Segment"){i},endTOS{i});
jointTOSnew1{i,:} = sortrows(jointTOS{i}(ismember(jointTOS{i}.Z,5),:),2);
jointTOSnew2{i,:} = sortrows(jointTOS{i}(ismember(jointTOS{i}.Z,10),:),2);
jointTOSnew{i,:} = vertcat(jointTOSnew1{i},jointTOSnew2{i});
end
here the resut that i want :
jointTOSnew{1}hi guys, can u tell me a different way to sort table by 2 variable columns which more simple than my method?
I want to sort jointTOS by its X and Z from minimum to maximum but X is the priority.
Here the code :
clear;
clc;
H = 5;
L = 15;
Ns = 2;
Nb = 1;
PortalHeight = H;
Bayspan = L;
NumberStory = Ns;
NumberBay = Nb;
% Variable1
h = [0.8,1.00,1.20,1.40,1.6,1.80];
% Variable2
Lss = [2.00,2.40,2.80,3.20,3.60,4.00];
% Variable3
Nss = [2,3,4];
% Definition
Var1HeightofTrussBeam = h;
Var2LengthSpecialSegment = Lss;
Var3NumberSpecialSegment = Nss;
% % Xbase = zeros(1,length(Totalvariant));
% % Zbase = zeros(1,length(Totalvariant));
% % Xcol = zeros(1,length(Totalvariant));
% % Zcol = zeros(1,length(Totalvariant));
% % Xos = zeros(1,length(Totalvariant));
% % Zos = zeros(1,length(Totalvariant));
% % Xss = zeros(1,length(Totalvariant));
% % Zss = zeros(1,length(Totalvariant));
% % X = zeros(1,length(Totalvariant));
% % Z = zeros(1,length(Totalvariant));
% % jointbase = zeros(1,length(Totalvariant));
% % jointcolumn = zeros(1,length(Totalvariant));
% % jointordinarysegment = zeros(1,length(Totalvariant));
% % jointtopordinarysegment = zeros(1,length(Totalvariant));
% % jointbottomordinarysegment = zeros(1,length(Totalvariant));
% % jointspecialsegment = zeros(1,length(Totalvariant));
% % jointtopspecialsegment = zeros(1,length(Totalvariant));
% % jointbottomspecialsegment = zeros(1,length(Totalvariant));
ijk = 0;
for i = 1:numel(h)
for j = 1:numel(Lss)
for k = 1:numel(Nss)
ijk = ijk+1;
Variantmodel{ijk,:} = table(ijk,h(i),Lss(j),Nss(k),’VariableNames’,{‘VariantID’,’Height’,’Length’,’Number’});
%% Cooridinate Point Base(base)
Xbase{ijk,:} = L*(0:NumberBay);
Zbase{ijk,:} = repelem(0,1,length(Xbase{ijk,:}));
%% Column(col)
Xcolumn = L*(0:NumberBay);
Zcolumn = repelem(H*(1:NumberStory),1,length(Xcolumn));
Xbotbeam = L*(0:NumberBay);
Zbotbeam = repelem((H*(1:NumberStory)-h(i)),1,length(Xbotbeam));
% replicate [X] to be the same size as [Z] for plotting:
Xcol{ijk,:} = repmat([Xcolumn,Xbotbeam],1,NumberStory);
Zcol{ijk,:} = [Zcolumn,Zbotbeam];
%% Cooridinate Point Ordinary Segment (os)
% calculate span length of ordinary segment
Los = (L-Lss(j))/2;
Nos = Los/h(i);
Nos = round(Nos);
los = Los/Nos;
totalspan{ijk,:} = los*Nos*2+Lss(j);
if totalspan{ijk,:} == 15.000
checkspan{ijk,:} = "correct span";
else
checkspan{ijk,:} = "span must be 15m";
end
% top and bottom joint of ordinary segment(os)
XTopOrdinarySegment = reshape([los*(1:Nos),(L/2+Lss(j)/2)+los*(0:Nos-1)].’+L*(0:(NumberBay-1)),1,[]);
XBottomOrdinarySegment = XTopOrdinarySegment;
ZTopOrdinarySegment = repelem(H*(1:NumberStory),1,2*Nos*NumberBay);
ZBottomOrdinarySegment = repelem(H*(1:NumberStory)-h(i),1,2*Nos*NumberBay);
% replicate [X] to be the same size as [Z] for plotting:
Xos{ijk,:} = repmat([XTopOrdinarySegment,XBottomOrdinarySegment],1,NumberStory);
Zos{ijk,:} = [ZTopOrdinarySegment,ZBottomOrdinarySegment];
%% Cooridinate Point Special Segment (ss)
% calculate span length of special segment
lss = Lss(j)/Nss(k);
% top and bottom joint of special segment(ss)
XTopSpecialSegment = reshape((lss*(0:Nss(k))+L/2-Lss(j)/2).’+L*(0:(NumberBay-1)),1,[]);
XBottomSpecialSegment = XTopSpecialSegment;
ZTopSpecialSegment = repelem(H*(1:NumberStory),1,length(XTopSpecialSegment));
ZBottomSpecialSegment = repelem(H*(1:NumberStory)-h(i),1,length(XBottomSpecialSegment));
% replicate [X] to be the same size as [Z] for plotting:
Xss{ijk,:} = repmat([XTopSpecialSegment,XBottomSpecialSegment],1,NumberStory);
Zss{ijk,:} = [ZTopSpecialSegment,ZBottomSpecialSegment];
%% Plot Cooridinate Point (X,Z)
X{ijk,:} = [Xbase{ijk,:},Xcol{ijk,:},Xos{ijk,:},Xss{ijk,:}];
Z{ijk,:} = [Zbase{ijk,:},Zcol{ijk,:},Zos{ijk,:},Zss{ijk,:}];
scatter(X{ijk,:},Z{ijk,:},’filled’),grid on
%check angle
tangent = (Lss(j)/Nss(k))/h(i);
anglespecialsegment(ijk) = atand(tangent);
%% Name the Joint
jointbase{ijk} = table((1:numel(Xbase{ijk,:}))’,Xbase{ijk,:}’,Zbase{ijk,:}’,’VariableNames’,{‘ID’,’X’,’Z’});
jointcolumn{ijk} = table((max(jointbase{ijk}.ID)+1:numel(Xcol{ijk,:})+max(jointbase{ijk}.ID))’,Xcol{ijk,:}’,Zcol{ijk,:}’,’VariableNames’,{‘ID’,’X’,’Z’});
jointordinarysegment{ijk} = table((max(jointcolumn{ijk}.ID)+1:numel(Xos{ijk,:})+max(jointcolumn{ijk}.ID))’,Xos{ijk,:}’,Zos{ijk,:}’,’VariableNames’,{‘ID’,’X’,’Z’});
jointtopordinarysegment{ijk} = jointordinarysegment{ijk}(ismember(jointordinarysegment{ijk}.Z,Zcolumn),:);
jointbottomordinarysegment{ijk} = jointordinarysegment{ijk}(ismember(jointordinarysegment{ijk}.Z,Zbotbeam),:);
jointspecialsegment{ijk} = table((max(jointbottomordinarysegment{ijk}.ID)+1:numel(Xss{ijk,:})+max(jointbottomordinarysegment{ijk}.ID))’,Xss{ijk,:}’,Zss{ijk,:}’,’VariableNames’,{‘ID’,’X’,’Z’});
jointtopspecialsegment{ijk} = jointspecialsegment{ijk}(ismember(jointspecialsegment{ijk}.Z,Zcolumn),:);
jointbottomspecialsegment{ijk} = jointspecialsegment{ijk}(ismember(jointspecialsegment{ijk}.Z,Zbotbeam),:);
end
end
end
% Verify Variants Which Passed the Angle Requirement
tablecheck = table((1:numel(anglespecialsegment))’,totalspan,anglespecialsegment’,’VariableNames’,{‘VariantID’,’Total Span’,’Angle’});
VariantIDPassed = tablecheck.VariantID(tablecheck.Angle>=30 & tablecheck.Angle<=60);
jointbase = table((1:numel(jointbase))’,jointbase’,’VariableNames’,{‘VariantID’,’Joint Base’});
jointbase = jointbase(ismember(jointbase.VariantID,VariantIDPassed),:);
jointcolumn = table((1:numel(jointcolumn))’,jointcolumn’,’VariableNames’,{‘VariantID’,’Joint Column’});
jointcolumn = jointcolumn(ismember(jointcolumn.VariantID,VariantIDPassed),:);
jointtopordinarysegment = table((1:numel(jointtopordinarysegment))’,jointtopordinarysegment’,’VariableNames’,{‘VariantID’,’Joint Top Ordinary Segment’});
jointtopordinarysegment = jointtopordinarysegment(ismember(jointtopordinarysegment.VariantID,VariantIDPassed),:);
jointbottomordinarysegment = table((1:numel(jointbottomordinarysegment))’,jointbottomordinarysegment’,’VariableNames’,{‘VariantID’,’Joint Bottom Ordinary Segment’});
jointbottomordinarysegment = jointbottomordinarysegment(ismember(jointbottomordinarysegment.VariantID,VariantIDPassed),:);
jointtopspecialsegment = table((1:numel(jointtopspecialsegment))’,jointtopspecialsegment’,’VariableNames’,{‘VariantID’,’Joint Top Special Segment’});
jointtopspecialsegment = jointtopspecialsegment(ismember(jointtopspecialsegment.VariantID,VariantIDPassed),:);
jointbottomspecialsegment = table((1:numel(jointbottomspecialsegment))’,jointbottomspecialsegment’,’VariableNames’,{‘VariantID’,’Joint Bottom Special Segment’});
jointbottomspecialsegment = jointbottomspecialsegment(ismember(jointbottomspecialsegment.VariantID,VariantIDPassed),:);
%% Name the Frame
% column
for i = 1:height(VariantIDPassed)
jointIcolumn = 0;
jointJcolumn = 0;
jointcolumnnew{i,:} = jointcolumn.("Joint Column"){i}(ismember(jointcolumn.("Joint Column"){i}.Z,Zcolumn),:);
jointcolumnnew{i,:} = vertcat(jointbase.("Joint Base"){i},jointcolumnnew{i});
for j = 1:height(jointcolumnnew{i,1})-2
jointIcolumn(j) = jointcolumnnew{i,1}.ID(j);
jointJcolumn(j) = jointcolumnnew{i,1}.ID(j+2);
end
framecolumn{i,:} = table((1:j)’,jointIcolumn’,jointJcolumn’,’VariableNames’,{‘Frame ID’,’JointI’,’JoinJ’});
end
% top ordinary segment (TOS)
for i = 1:height(VariantIDPassed)
endTOS{i,:} = jointcolumn.("Joint Column"){i}(ismember(jointcolumn.("Joint Column"){i}.Z,Zcolumn),:);
jointTOS{i,:} = vertcat(jointtopordinarysegment.("Joint Top Ordinary Segment"){i},endTOS{i});
jointTOSnew1{i,:} = sortrows(jointTOS{i}(ismember(jointTOS{i}.Z,5),:),2);
jointTOSnew2{i,:} = sortrows(jointTOS{i}(ismember(jointTOS{i}.Z,10),:),2);
jointTOSnew{i,:} = vertcat(jointTOSnew1{i},jointTOSnew2{i});
end
here the resut that i want :
jointTOSnew{1} hi guys, can u tell me a different way to sort table by 2 variable columns which more simple than my method?
I want to sort jointTOS by its X and Z from minimum to maximum but X is the priority.
Here the code :
clear;
clc;
H = 5;
L = 15;
Ns = 2;
Nb = 1;
PortalHeight = H;
Bayspan = L;
NumberStory = Ns;
NumberBay = Nb;
% Variable1
h = [0.8,1.00,1.20,1.40,1.6,1.80];
% Variable2
Lss = [2.00,2.40,2.80,3.20,3.60,4.00];
% Variable3
Nss = [2,3,4];
% Definition
Var1HeightofTrussBeam = h;
Var2LengthSpecialSegment = Lss;
Var3NumberSpecialSegment = Nss;
% % Xbase = zeros(1,length(Totalvariant));
% % Zbase = zeros(1,length(Totalvariant));
% % Xcol = zeros(1,length(Totalvariant));
% % Zcol = zeros(1,length(Totalvariant));
% % Xos = zeros(1,length(Totalvariant));
% % Zos = zeros(1,length(Totalvariant));
% % Xss = zeros(1,length(Totalvariant));
% % Zss = zeros(1,length(Totalvariant));
% % X = zeros(1,length(Totalvariant));
% % Z = zeros(1,length(Totalvariant));
% % jointbase = zeros(1,length(Totalvariant));
% % jointcolumn = zeros(1,length(Totalvariant));
% % jointordinarysegment = zeros(1,length(Totalvariant));
% % jointtopordinarysegment = zeros(1,length(Totalvariant));
% % jointbottomordinarysegment = zeros(1,length(Totalvariant));
% % jointspecialsegment = zeros(1,length(Totalvariant));
% % jointtopspecialsegment = zeros(1,length(Totalvariant));
% % jointbottomspecialsegment = zeros(1,length(Totalvariant));
ijk = 0;
for i = 1:numel(h)
for j = 1:numel(Lss)
for k = 1:numel(Nss)
ijk = ijk+1;
Variantmodel{ijk,:} = table(ijk,h(i),Lss(j),Nss(k),’VariableNames’,{‘VariantID’,’Height’,’Length’,’Number’});
%% Cooridinate Point Base(base)
Xbase{ijk,:} = L*(0:NumberBay);
Zbase{ijk,:} = repelem(0,1,length(Xbase{ijk,:}));
%% Column(col)
Xcolumn = L*(0:NumberBay);
Zcolumn = repelem(H*(1:NumberStory),1,length(Xcolumn));
Xbotbeam = L*(0:NumberBay);
Zbotbeam = repelem((H*(1:NumberStory)-h(i)),1,length(Xbotbeam));
% replicate [X] to be the same size as [Z] for plotting:
Xcol{ijk,:} = repmat([Xcolumn,Xbotbeam],1,NumberStory);
Zcol{ijk,:} = [Zcolumn,Zbotbeam];
%% Cooridinate Point Ordinary Segment (os)
% calculate span length of ordinary segment
Los = (L-Lss(j))/2;
Nos = Los/h(i);
Nos = round(Nos);
los = Los/Nos;
totalspan{ijk,:} = los*Nos*2+Lss(j);
if totalspan{ijk,:} == 15.000
checkspan{ijk,:} = "correct span";
else
checkspan{ijk,:} = "span must be 15m";
end
% top and bottom joint of ordinary segment(os)
XTopOrdinarySegment = reshape([los*(1:Nos),(L/2+Lss(j)/2)+los*(0:Nos-1)].’+L*(0:(NumberBay-1)),1,[]);
XBottomOrdinarySegment = XTopOrdinarySegment;
ZTopOrdinarySegment = repelem(H*(1:NumberStory),1,2*Nos*NumberBay);
ZBottomOrdinarySegment = repelem(H*(1:NumberStory)-h(i),1,2*Nos*NumberBay);
% replicate [X] to be the same size as [Z] for plotting:
Xos{ijk,:} = repmat([XTopOrdinarySegment,XBottomOrdinarySegment],1,NumberStory);
Zos{ijk,:} = [ZTopOrdinarySegment,ZBottomOrdinarySegment];
%% Cooridinate Point Special Segment (ss)
% calculate span length of special segment
lss = Lss(j)/Nss(k);
% top and bottom joint of special segment(ss)
XTopSpecialSegment = reshape((lss*(0:Nss(k))+L/2-Lss(j)/2).’+L*(0:(NumberBay-1)),1,[]);
XBottomSpecialSegment = XTopSpecialSegment;
ZTopSpecialSegment = repelem(H*(1:NumberStory),1,length(XTopSpecialSegment));
ZBottomSpecialSegment = repelem(H*(1:NumberStory)-h(i),1,length(XBottomSpecialSegment));
% replicate [X] to be the same size as [Z] for plotting:
Xss{ijk,:} = repmat([XTopSpecialSegment,XBottomSpecialSegment],1,NumberStory);
Zss{ijk,:} = [ZTopSpecialSegment,ZBottomSpecialSegment];
%% Plot Cooridinate Point (X,Z)
X{ijk,:} = [Xbase{ijk,:},Xcol{ijk,:},Xos{ijk,:},Xss{ijk,:}];
Z{ijk,:} = [Zbase{ijk,:},Zcol{ijk,:},Zos{ijk,:},Zss{ijk,:}];
scatter(X{ijk,:},Z{ijk,:},’filled’),grid on
%check angle
tangent = (Lss(j)/Nss(k))/h(i);
anglespecialsegment(ijk) = atand(tangent);
%% Name the Joint
jointbase{ijk} = table((1:numel(Xbase{ijk,:}))’,Xbase{ijk,:}’,Zbase{ijk,:}’,’VariableNames’,{‘ID’,’X’,’Z’});
jointcolumn{ijk} = table((max(jointbase{ijk}.ID)+1:numel(Xcol{ijk,:})+max(jointbase{ijk}.ID))’,Xcol{ijk,:}’,Zcol{ijk,:}’,’VariableNames’,{‘ID’,’X’,’Z’});
jointordinarysegment{ijk} = table((max(jointcolumn{ijk}.ID)+1:numel(Xos{ijk,:})+max(jointcolumn{ijk}.ID))’,Xos{ijk,:}’,Zos{ijk,:}’,’VariableNames’,{‘ID’,’X’,’Z’});
jointtopordinarysegment{ijk} = jointordinarysegment{ijk}(ismember(jointordinarysegment{ijk}.Z,Zcolumn),:);
jointbottomordinarysegment{ijk} = jointordinarysegment{ijk}(ismember(jointordinarysegment{ijk}.Z,Zbotbeam),:);
jointspecialsegment{ijk} = table((max(jointbottomordinarysegment{ijk}.ID)+1:numel(Xss{ijk,:})+max(jointbottomordinarysegment{ijk}.ID))’,Xss{ijk,:}’,Zss{ijk,:}’,’VariableNames’,{‘ID’,’X’,’Z’});
jointtopspecialsegment{ijk} = jointspecialsegment{ijk}(ismember(jointspecialsegment{ijk}.Z,Zcolumn),:);
jointbottomspecialsegment{ijk} = jointspecialsegment{ijk}(ismember(jointspecialsegment{ijk}.Z,Zbotbeam),:);
end
end
end
% Verify Variants Which Passed the Angle Requirement
tablecheck = table((1:numel(anglespecialsegment))’,totalspan,anglespecialsegment’,’VariableNames’,{‘VariantID’,’Total Span’,’Angle’});
VariantIDPassed = tablecheck.VariantID(tablecheck.Angle>=30 & tablecheck.Angle<=60);
jointbase = table((1:numel(jointbase))’,jointbase’,’VariableNames’,{‘VariantID’,’Joint Base’});
jointbase = jointbase(ismember(jointbase.VariantID,VariantIDPassed),:);
jointcolumn = table((1:numel(jointcolumn))’,jointcolumn’,’VariableNames’,{‘VariantID’,’Joint Column’});
jointcolumn = jointcolumn(ismember(jointcolumn.VariantID,VariantIDPassed),:);
jointtopordinarysegment = table((1:numel(jointtopordinarysegment))’,jointtopordinarysegment’,’VariableNames’,{‘VariantID’,’Joint Top Ordinary Segment’});
jointtopordinarysegment = jointtopordinarysegment(ismember(jointtopordinarysegment.VariantID,VariantIDPassed),:);
jointbottomordinarysegment = table((1:numel(jointbottomordinarysegment))’,jointbottomordinarysegment’,’VariableNames’,{‘VariantID’,’Joint Bottom Ordinary Segment’});
jointbottomordinarysegment = jointbottomordinarysegment(ismember(jointbottomordinarysegment.VariantID,VariantIDPassed),:);
jointtopspecialsegment = table((1:numel(jointtopspecialsegment))’,jointtopspecialsegment’,’VariableNames’,{‘VariantID’,’Joint Top Special Segment’});
jointtopspecialsegment = jointtopspecialsegment(ismember(jointtopspecialsegment.VariantID,VariantIDPassed),:);
jointbottomspecialsegment = table((1:numel(jointbottomspecialsegment))’,jointbottomspecialsegment’,’VariableNames’,{‘VariantID’,’Joint Bottom Special Segment’});
jointbottomspecialsegment = jointbottomspecialsegment(ismember(jointbottomspecialsegment.VariantID,VariantIDPassed),:);
%% Name the Frame
% column
for i = 1:height(VariantIDPassed)
jointIcolumn = 0;
jointJcolumn = 0;
jointcolumnnew{i,:} = jointcolumn.("Joint Column"){i}(ismember(jointcolumn.("Joint Column"){i}.Z,Zcolumn),:);
jointcolumnnew{i,:} = vertcat(jointbase.("Joint Base"){i},jointcolumnnew{i});
for j = 1:height(jointcolumnnew{i,1})-2
jointIcolumn(j) = jointcolumnnew{i,1}.ID(j);
jointJcolumn(j) = jointcolumnnew{i,1}.ID(j+2);
end
framecolumn{i,:} = table((1:j)’,jointIcolumn’,jointJcolumn’,’VariableNames’,{‘Frame ID’,’JointI’,’JoinJ’});
end
% top ordinary segment (TOS)
for i = 1:height(VariantIDPassed)
endTOS{i,:} = jointcolumn.("Joint Column"){i}(ismember(jointcolumn.("Joint Column"){i}.Z,Zcolumn),:);
jointTOS{i,:} = vertcat(jointtopordinarysegment.("Joint Top Ordinary Segment"){i},endTOS{i});
jointTOSnew1{i,:} = sortrows(jointTOS{i}(ismember(jointTOS{i}.Z,5),:),2);
jointTOSnew2{i,:} = sortrows(jointTOS{i}(ismember(jointTOS{i}.Z,10),:),2);
jointTOSnew{i,:} = vertcat(jointTOSnew1{i},jointTOSnew2{i});
end
here the resut that i want :
jointTOSnew{1} sort MATLAB Answers — New Questions
Plot a 2D matrix using a color plot
I have a 3D matrix where the spans an angle , the spans a value for a radius and the spans a set of times. The value in the entry is a positive number. What I would like to do is to plot, for each , a 2D colored map of the matrix such that in the point of coordinates () it plots a color depending on the value of . In particular if I would like a specific color, say green, while the more approaches 0 I would like another color to be plotted, say blue, and red if becomes larger than 1.I have a 3D matrix where the spans an angle , the spans a value for a radius and the spans a set of times. The value in the entry is a positive number. What I would like to do is to plot, for each , a 2D colored map of the matrix such that in the point of coordinates () it plots a color depending on the value of . In particular if I would like a specific color, say green, while the more approaches 0 I would like another color to be plotted, say blue, and red if becomes larger than 1. I have a 3D matrix where the spans an angle , the spans a value for a radius and the spans a set of times. The value in the entry is a positive number. What I would like to do is to plot, for each , a 2D colored map of the matrix such that in the point of coordinates () it plots a color depending on the value of . In particular if I would like a specific color, say green, while the more approaches 0 I would like another color to be plotted, say blue, and red if becomes larger than 1. colormap, plot, plotting MATLAB Answers — New Questions
Using SIMULINK, develop the models for controlled rectifiers (1, 4, 6 and 12 pulse) and compare THD to find which rectifier will be suitable for MEA.
this is the table for the parameters Three-Phase Source Block Phase-to-phase voltage (Vrms) 254V Frequency 50Hz PLL Block Minimum frequency 50Hz Pulse Generator (Thyristor, 12 pulse) Block Pulse Width (deg) 60 Three-Phase Transformer (Three Windings) Block Nominal power and frequency [1000VA , 50 Hz] Winding 1 parameters [254.04 0 0] Winding 2 parameters [254.04 0 0] Winding 3 parameters [254.04 0 0] is set for below mentioned blocks in rectifier modelling. hence Explain the graphical results you getting from scopes and Displays for all rectifier types and Explain which rectifier will perform better in More Electric Aircraft and Why?this is the table for the parameters Three-Phase Source Block Phase-to-phase voltage (Vrms) 254V Frequency 50Hz PLL Block Minimum frequency 50Hz Pulse Generator (Thyristor, 12 pulse) Block Pulse Width (deg) 60 Three-Phase Transformer (Three Windings) Block Nominal power and frequency [1000VA , 50 Hz] Winding 1 parameters [254.04 0 0] Winding 2 parameters [254.04 0 0] Winding 3 parameters [254.04 0 0] is set for below mentioned blocks in rectifier modelling. hence Explain the graphical results you getting from scopes and Displays for all rectifier types and Explain which rectifier will perform better in More Electric Aircraft and Why? this is the table for the parameters Three-Phase Source Block Phase-to-phase voltage (Vrms) 254V Frequency 50Hz PLL Block Minimum frequency 50Hz Pulse Generator (Thyristor, 12 pulse) Block Pulse Width (deg) 60 Three-Phase Transformer (Three Windings) Block Nominal power and frequency [1000VA , 50 Hz] Winding 1 parameters [254.04 0 0] Winding 2 parameters [254.04 0 0] Winding 3 parameters [254.04 0 0] is set for below mentioned blocks in rectifier modelling. hence Explain the graphical results you getting from scopes and Displays for all rectifier types and Explain which rectifier will perform better in More Electric Aircraft and Why? simulink MATLAB Answers — New Questions
Simulation of Full-Bridge LLC Resonant Converter
I want to simulate the full-bridge LLC resonant circuit in Simulink, unfortunately, I am a beginner in Simulink , Can anyone model the circuit as follwoed in Simulink and send me simulink model in response, please.
I want a general model in Simulink, please.
I am really stuck with it, please help.
Thanks in advance
<</matlabcentral/answers/uploaded_files/67733/full-bridge_LLC_converter.png>>I want to simulate the full-bridge LLC resonant circuit in Simulink, unfortunately, I am a beginner in Simulink , Can anyone model the circuit as follwoed in Simulink and send me simulink model in response, please.
I want a general model in Simulink, please.
I am really stuck with it, please help.
Thanks in advance
<</matlabcentral/answers/uploaded_files/67733/full-bridge_LLC_converter.png>> I want to simulate the full-bridge LLC resonant circuit in Simulink, unfortunately, I am a beginner in Simulink , Can anyone model the circuit as follwoed in Simulink and send me simulink model in response, please.
I want a general model in Simulink, please.
I am really stuck with it, please help.
Thanks in advance
<</matlabcentral/answers/uploaded_files/67733/full-bridge_LLC_converter.png>> simulation of full-bridge llc resonant converter MATLAB Answers — New Questions
I am getting error:Warning: Failure at t=0.000000e+00. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (7.905050e-323)
This is my code
clc
clear
global datei Temp c0
datei=’input_data.m’;
run(datei);
zspan=[0 V/A_hc];
%intergration of the system
options=odeset(‘RelTol’,1e-12,’AbsTol’,1e-12);%,’NonNegative’,2:7);
for n=1:size(c,1)
switch dataset
case 1
name=[experiment ‘ ‘ num2str(y0_nh3_scr(n,2)) ‘ ppm NH3 ‘ num2str(y0_nh3_scr(n,1)) ‘ vol NO ‘ num2str(y0_nh3_scr(n,5)) ‘% O2’ ];
case 2
name=[experiment ‘ ‘ num2str(y0_nh3_ox(n,2)) ‘ ppm NH3 ‘ num2str(y0_nh3_ox(n,5)) ‘ vol O2’];
case 3
name=[experiment ‘ ‘ num2str(y0_hcho_ox(n,3)) ‘ ppm HCHO ‘ num2str(y0_hcho_ox(n,5)) ‘ vol O2’];
end
results=zeros(length(T),size(c,2)+2);
for m=1:length(T)
c0=c(n,1:4).*T_N./T(m);
c_o2=c0_o2(n).*T_N./T(m);
p_o2=p0_o2(n);
y0=[c0 0];
Temp=T(m);
tic
disp([‘Calculating Step ‘ num2str(m) ‘ of ‘ num2str(length(T))])
[t,y]=ode15s(@massbalance,zspan,y0,options);
toc
results(m,:)=[T(m)-273.15 y(end,:)];
end
end
results(:,2:5)=results(:,2:5).*Vm.*1e6.*(results(:,1)+273.15)./T_N;
switch dataset
case 1
results(:,2:3)=(1-results(:,2:3)./y0_nh3_scr(n,1:2)).*100;
case 2
results(:,3)=(1-results(:,3)./y0_nh3_ox(n,2)).*100;
case 3
results(:,4)=(1-results(:,4)./y0_hcho_ox(n,3)).*100;
end
name=[name ‘ ‘ char(num2str(fix(clock)))];
save(name,’results’,’-double’,’-ascii’)
plot(results(:,1),results(:,2),’b’,results(:,1),results(:,3),’r’,results(:,1),results(:,6),’g’)
xlabel(‘T / ^oC’)
ylabel(‘y / ppm’)
legend(‘NO’,’NH3′,’N2O’)
function dy_dz = massbalance(takt,y)
global datei Temp c0
run(datei)
F=F*Temp/T_N;
u=F/A_hc;
if c0(1)==0
kin=kin_ox;
else
kin=kin_scr;
end
r1=kin(1,1).*exp(-kin(1,2)./R.*(1/Temp-1/kin(1,3))).*y(2).*(1-y(5));
r2=kin(2,1).*exp(-(kin(2,2)-y(5).*kin(2,3))./(R.*Temp)).*y(5);
r3=kin(3,1).*exp(-kin(3,2)./(R.*Temp)).*y(1).*y(5);
r4=kin(4,1).*exp(-kin(4,2)./(R.*Temp)).*y(5);
r5=kin(5,1).*exp(-kin(5,2)./(R.*Temp)).*y(4);
r6=kin(6,1).*exp(-kin(6,2.)/(R.*Temp)).*y(3);
%% mass balances
dy_dz=[1/u*(-r3)
1/u*(-r1+r2)
1/u*(-r6)
1/u*(-r5)
(r1-r2-r3-r4)/(u*gam)];
end
I am not able to figure out where I am making a mistake. I appricate all the help in advance.This is my code
clc
clear
global datei Temp c0
datei=’input_data.m’;
run(datei);
zspan=[0 V/A_hc];
%intergration of the system
options=odeset(‘RelTol’,1e-12,’AbsTol’,1e-12);%,’NonNegative’,2:7);
for n=1:size(c,1)
switch dataset
case 1
name=[experiment ‘ ‘ num2str(y0_nh3_scr(n,2)) ‘ ppm NH3 ‘ num2str(y0_nh3_scr(n,1)) ‘ vol NO ‘ num2str(y0_nh3_scr(n,5)) ‘% O2’ ];
case 2
name=[experiment ‘ ‘ num2str(y0_nh3_ox(n,2)) ‘ ppm NH3 ‘ num2str(y0_nh3_ox(n,5)) ‘ vol O2’];
case 3
name=[experiment ‘ ‘ num2str(y0_hcho_ox(n,3)) ‘ ppm HCHO ‘ num2str(y0_hcho_ox(n,5)) ‘ vol O2’];
end
results=zeros(length(T),size(c,2)+2);
for m=1:length(T)
c0=c(n,1:4).*T_N./T(m);
c_o2=c0_o2(n).*T_N./T(m);
p_o2=p0_o2(n);
y0=[c0 0];
Temp=T(m);
tic
disp([‘Calculating Step ‘ num2str(m) ‘ of ‘ num2str(length(T))])
[t,y]=ode15s(@massbalance,zspan,y0,options);
toc
results(m,:)=[T(m)-273.15 y(end,:)];
end
end
results(:,2:5)=results(:,2:5).*Vm.*1e6.*(results(:,1)+273.15)./T_N;
switch dataset
case 1
results(:,2:3)=(1-results(:,2:3)./y0_nh3_scr(n,1:2)).*100;
case 2
results(:,3)=(1-results(:,3)./y0_nh3_ox(n,2)).*100;
case 3
results(:,4)=(1-results(:,4)./y0_hcho_ox(n,3)).*100;
end
name=[name ‘ ‘ char(num2str(fix(clock)))];
save(name,’results’,’-double’,’-ascii’)
plot(results(:,1),results(:,2),’b’,results(:,1),results(:,3),’r’,results(:,1),results(:,6),’g’)
xlabel(‘T / ^oC’)
ylabel(‘y / ppm’)
legend(‘NO’,’NH3′,’N2O’)
function dy_dz = massbalance(takt,y)
global datei Temp c0
run(datei)
F=F*Temp/T_N;
u=F/A_hc;
if c0(1)==0
kin=kin_ox;
else
kin=kin_scr;
end
r1=kin(1,1).*exp(-kin(1,2)./R.*(1/Temp-1/kin(1,3))).*y(2).*(1-y(5));
r2=kin(2,1).*exp(-(kin(2,2)-y(5).*kin(2,3))./(R.*Temp)).*y(5);
r3=kin(3,1).*exp(-kin(3,2)./(R.*Temp)).*y(1).*y(5);
r4=kin(4,1).*exp(-kin(4,2)./(R.*Temp)).*y(5);
r5=kin(5,1).*exp(-kin(5,2)./(R.*Temp)).*y(4);
r6=kin(6,1).*exp(-kin(6,2.)/(R.*Temp)).*y(3);
%% mass balances
dy_dz=[1/u*(-r3)
1/u*(-r1+r2)
1/u*(-r6)
1/u*(-r5)
(r1-r2-r3-r4)/(u*gam)];
end
I am not able to figure out where I am making a mistake. I appricate all the help in advance. This is my code
clc
clear
global datei Temp c0
datei=’input_data.m’;
run(datei);
zspan=[0 V/A_hc];
%intergration of the system
options=odeset(‘RelTol’,1e-12,’AbsTol’,1e-12);%,’NonNegative’,2:7);
for n=1:size(c,1)
switch dataset
case 1
name=[experiment ‘ ‘ num2str(y0_nh3_scr(n,2)) ‘ ppm NH3 ‘ num2str(y0_nh3_scr(n,1)) ‘ vol NO ‘ num2str(y0_nh3_scr(n,5)) ‘% O2’ ];
case 2
name=[experiment ‘ ‘ num2str(y0_nh3_ox(n,2)) ‘ ppm NH3 ‘ num2str(y0_nh3_ox(n,5)) ‘ vol O2’];
case 3
name=[experiment ‘ ‘ num2str(y0_hcho_ox(n,3)) ‘ ppm HCHO ‘ num2str(y0_hcho_ox(n,5)) ‘ vol O2’];
end
results=zeros(length(T),size(c,2)+2);
for m=1:length(T)
c0=c(n,1:4).*T_N./T(m);
c_o2=c0_o2(n).*T_N./T(m);
p_o2=p0_o2(n);
y0=[c0 0];
Temp=T(m);
tic
disp([‘Calculating Step ‘ num2str(m) ‘ of ‘ num2str(length(T))])
[t,y]=ode15s(@massbalance,zspan,y0,options);
toc
results(m,:)=[T(m)-273.15 y(end,:)];
end
end
results(:,2:5)=results(:,2:5).*Vm.*1e6.*(results(:,1)+273.15)./T_N;
switch dataset
case 1
results(:,2:3)=(1-results(:,2:3)./y0_nh3_scr(n,1:2)).*100;
case 2
results(:,3)=(1-results(:,3)./y0_nh3_ox(n,2)).*100;
case 3
results(:,4)=(1-results(:,4)./y0_hcho_ox(n,3)).*100;
end
name=[name ‘ ‘ char(num2str(fix(clock)))];
save(name,’results’,’-double’,’-ascii’)
plot(results(:,1),results(:,2),’b’,results(:,1),results(:,3),’r’,results(:,1),results(:,6),’g’)
xlabel(‘T / ^oC’)
ylabel(‘y / ppm’)
legend(‘NO’,’NH3′,’N2O’)
function dy_dz = massbalance(takt,y)
global datei Temp c0
run(datei)
F=F*Temp/T_N;
u=F/A_hc;
if c0(1)==0
kin=kin_ox;
else
kin=kin_scr;
end
r1=kin(1,1).*exp(-kin(1,2)./R.*(1/Temp-1/kin(1,3))).*y(2).*(1-y(5));
r2=kin(2,1).*exp(-(kin(2,2)-y(5).*kin(2,3))./(R.*Temp)).*y(5);
r3=kin(3,1).*exp(-kin(3,2)./(R.*Temp)).*y(1).*y(5);
r4=kin(4,1).*exp(-kin(4,2)./(R.*Temp)).*y(5);
r5=kin(5,1).*exp(-kin(5,2)./(R.*Temp)).*y(4);
r6=kin(6,1).*exp(-kin(6,2.)/(R.*Temp)).*y(3);
%% mass balances
dy_dz=[1/u*(-r3)
1/u*(-r1+r2)
1/u*(-r6)
1/u*(-r5)
(r1-r2-r3-r4)/(u*gam)];
end
I am not able to figure out where I am making a mistake. I appricate all the help in advance. ode, function MATLAB Answers — New Questions
Condition for if-statement not updating inside for-loop without pause function
Hello!
I want to break from a for-loop when I close a plot. This is the code I use:
cscale = 100; %The number of colours in the colormap of choice
for c2 = 1:length(time)
f2 = figure(2);
p = plot(G);
G.Nodes.value = floor(real(cos(x(:,c2))+1)*((cscale-1)/2))+1; %scales x values to range from 1 up to cscale.
G.Edges.value = floor(real(cos(y(:,c2))+1)*((cscale-1)/2))+1; %scales y values to range from 1 up to cscale.
G.Nodes.NodeColors = G.Nodes.value;
G.Edges.EdgeColors = G.Edges.value;
p.NodeCData = G.Nodes.NodeColors;
p.EdgeCData = G.Edges.EdgeColors;
colormap(flipud(turbo(cscale)));
pause(1/5000);
if ~isgraphics(f2)
break;
end
end
The for-loop is not inside any other loop, so I shouldn’t need to break more than once to end the code. The above only worked when I introduced the pause function, no matter how short the pause is. Note that I tried changing the condition to ~isgraphics(f1) where f1 is another figure generated earlier in the code (unlike f2, f1 is not generated inside a loop), and I also tried ishghandle and ishandle, but without the pause function, they all kept returning a logical 0 even after I closed the figure, and hence the code didn’t break the loop. My question is why does it not work without pausing?
Any insight would be appreciated!Hello!
I want to break from a for-loop when I close a plot. This is the code I use:
cscale = 100; %The number of colours in the colormap of choice
for c2 = 1:length(time)
f2 = figure(2);
p = plot(G);
G.Nodes.value = floor(real(cos(x(:,c2))+1)*((cscale-1)/2))+1; %scales x values to range from 1 up to cscale.
G.Edges.value = floor(real(cos(y(:,c2))+1)*((cscale-1)/2))+1; %scales y values to range from 1 up to cscale.
G.Nodes.NodeColors = G.Nodes.value;
G.Edges.EdgeColors = G.Edges.value;
p.NodeCData = G.Nodes.NodeColors;
p.EdgeCData = G.Edges.EdgeColors;
colormap(flipud(turbo(cscale)));
pause(1/5000);
if ~isgraphics(f2)
break;
end
end
The for-loop is not inside any other loop, so I shouldn’t need to break more than once to end the code. The above only worked when I introduced the pause function, no matter how short the pause is. Note that I tried changing the condition to ~isgraphics(f1) where f1 is another figure generated earlier in the code (unlike f2, f1 is not generated inside a loop), and I also tried ishghandle and ishandle, but without the pause function, they all kept returning a logical 0 even after I closed the figure, and hence the code didn’t break the loop. My question is why does it not work without pausing?
Any insight would be appreciated! Hello!
I want to break from a for-loop when I close a plot. This is the code I use:
cscale = 100; %The number of colours in the colormap of choice
for c2 = 1:length(time)
f2 = figure(2);
p = plot(G);
G.Nodes.value = floor(real(cos(x(:,c2))+1)*((cscale-1)/2))+1; %scales x values to range from 1 up to cscale.
G.Edges.value = floor(real(cos(y(:,c2))+1)*((cscale-1)/2))+1; %scales y values to range from 1 up to cscale.
G.Nodes.NodeColors = G.Nodes.value;
G.Edges.EdgeColors = G.Edges.value;
p.NodeCData = G.Nodes.NodeColors;
p.EdgeCData = G.Edges.EdgeColors;
colormap(flipud(turbo(cscale)));
pause(1/5000);
if ~isgraphics(f2)
break;
end
end
The for-loop is not inside any other loop, so I shouldn’t need to break more than once to end the code. The above only worked when I introduced the pause function, no matter how short the pause is. Note that I tried changing the condition to ~isgraphics(f1) where f1 is another figure generated earlier in the code (unlike f2, f1 is not generated inside a loop), and I also tried ishghandle and ishandle, but without the pause function, they all kept returning a logical 0 even after I closed the figure, and hence the code didn’t break the loop. My question is why does it not work without pausing?
Any insight would be appreciated! figure, plot, break, if statement, loop, pause MATLAB Answers — New Questions
Unable to open matlab
Hi all, i am unable to open my matlab software. i keep being told "you do not have a valid license file" but my license is activatedHi all, i am unable to open my matlab software. i keep being told "you do not have a valid license file" but my license is activated Hi all, i am unable to open my matlab software. i keep being told "you do not have a valid license file" but my license is activated license MATLAB Answers — New Questions