Tag Archives: matlab
Which statistic is minimized in curve fitting app
Dear colleagues,
The statistics which evaluate the goodness of in the Curve Fitting app are shown in the picture below.
At this link is given a description of each of these.
https://nl.mathworks.com/help/curvefit/evaluating-goodness-of-fit.html
My question is what parameter/statistic is minimized to make a fit? In another discussion I have read something about 2-norm. So is some of shown above a 2-norm?Dear colleagues,
The statistics which evaluate the goodness of in the Curve Fitting app are shown in the picture below.
At this link is given a description of each of these.
https://nl.mathworks.com/help/curvefit/evaluating-goodness-of-fit.html
My question is what parameter/statistic is minimized to make a fit? In another discussion I have read something about 2-norm. So is some of shown above a 2-norm? Dear colleagues,
The statistics which evaluate the goodness of in the Curve Fitting app are shown in the picture below.
At this link is given a description of each of these.
https://nl.mathworks.com/help/curvefit/evaluating-goodness-of-fit.html
My question is what parameter/statistic is minimized to make a fit? In another discussion I have read something about 2-norm. So is some of shown above a 2-norm? curve fitting MATLAB Answers — New Questions
CRLB in Mean Square Error
in my code i am having FIM Function[ function [J_11, J_12, J_22] = FIM(para, Rx, beta, scale)]. i want to use this function in my dnn for MSE to calculate traces of CRLB. how i can doin my code i am having FIM Function[ function [J_11, J_12, J_22] = FIM(para, Rx, beta, scale)]. i want to use this function in my dnn for MSE to calculate traces of CRLB. how i can do in my code i am having FIM Function[ function [J_11, J_12, J_22] = FIM(para, Rx, beta, scale)]. i want to use this function in my dnn for MSE to calculate traces of CRLB. how i can do crlb, mse MATLAB Answers — New Questions
What happens if I set both RelTol and AbsTol for ODE45 and/or both TolX and Tolfun for FSOLVE?
I’m solving an eigenvalue problem via a combination of ODE45 and FSOLVE, and I’m not sure what happens if I set both RelTol and AbsTol for the former and both TolX and Tolfun for the latter. Do these functions refine steps, etc. until both requirements are satisfied or only one of them?I’m solving an eigenvalue problem via a combination of ODE45 and FSOLVE, and I’m not sure what happens if I set both RelTol and AbsTol for the former and both TolX and Tolfun for the latter. Do these functions refine steps, etc. until both requirements are satisfied or only one of them? I’m solving an eigenvalue problem via a combination of ODE45 and FSOLVE, and I’m not sure what happens if I set both RelTol and AbsTol for the former and both TolX and Tolfun for the latter. Do these functions refine steps, etc. until both requirements are satisfied or only one of them? ode45, fsolve, tolerance MATLAB Answers — New Questions
PNG file saving in power point presentation
clear
clc
%removed the clear all, close all, clc, as they are irrelevant here and can only cause problems
project_dir = pwd(); %new
% List all current folder contents ending with .png. Resulting names will
% appear in the order returned by the operating system.
files = dir( fullfile(project_dir, ‘*.png’)); %changed
% Create Common Object Model (COM) server so MATLAB can export data to
% PowerPoint
g = actxserver(‘powerpoint.application’);
% Open PowerPoint and make it visible
g.Visible = 1;
Presentation = g.Presentation;
% Prompt the user for the PowerPoint file to amend
[fn, pn] = uigetfile(‘*.pptx’, ‘Select PowerPoint File To Amend’);
filename = fullfile(pn, fn); %changed
Presentation = invoke(Presentation, ‘open’, filename);
% Get current number of slides
slide_count = get(Presentation.Slides, ‘Count’);
% Export all PNGs in the current directory to the PowerPoint file specified
% above. The following slides will be added to the END of the PowerPoint
% file. All slides will have a common title.
for i=1:length(files)
slide_count = int32(double(slide_count)+1);
slide = invoke(Presentation.Slides, ‘Add’, slide_count{i}, 11);
set(slide.Shapes.Title.Textframe.Textrange, ‘Text’, ‘SomeTitle’);
slidefile = fullfile(project_dir, files(i).name); %new
Image{i} = slide.Shapes.AddPicture(slidefile, ‘msoFalse’, ‘msoTrue’, 0, 80, 720, 440); %changed
end
% Save the amended PowerPoint presentation to the current directory
outfile = fullfile(project_dir, ‘DRAFT.pptx’); %new
Presentation.SaveAs(outfile); %changed
% Close PowerPoint as a COM automation server
g.Quit;
g.delete;
If i have 4 PNG images in a folder , how can i save (present) those in a single slide in power point using MATLAB code? I am using the code below but showing some error.clear
clc
%removed the clear all, close all, clc, as they are irrelevant here and can only cause problems
project_dir = pwd(); %new
% List all current folder contents ending with .png. Resulting names will
% appear in the order returned by the operating system.
files = dir( fullfile(project_dir, ‘*.png’)); %changed
% Create Common Object Model (COM) server so MATLAB can export data to
% PowerPoint
g = actxserver(‘powerpoint.application’);
% Open PowerPoint and make it visible
g.Visible = 1;
Presentation = g.Presentation;
% Prompt the user for the PowerPoint file to amend
[fn, pn] = uigetfile(‘*.pptx’, ‘Select PowerPoint File To Amend’);
filename = fullfile(pn, fn); %changed
Presentation = invoke(Presentation, ‘open’, filename);
% Get current number of slides
slide_count = get(Presentation.Slides, ‘Count’);
% Export all PNGs in the current directory to the PowerPoint file specified
% above. The following slides will be added to the END of the PowerPoint
% file. All slides will have a common title.
for i=1:length(files)
slide_count = int32(double(slide_count)+1);
slide = invoke(Presentation.Slides, ‘Add’, slide_count{i}, 11);
set(slide.Shapes.Title.Textframe.Textrange, ‘Text’, ‘SomeTitle’);
slidefile = fullfile(project_dir, files(i).name); %new
Image{i} = slide.Shapes.AddPicture(slidefile, ‘msoFalse’, ‘msoTrue’, 0, 80, 720, 440); %changed
end
% Save the amended PowerPoint presentation to the current directory
outfile = fullfile(project_dir, ‘DRAFT.pptx’); %new
Presentation.SaveAs(outfile); %changed
% Close PowerPoint as a COM automation server
g.Quit;
g.delete;
If i have 4 PNG images in a folder , how can i save (present) those in a single slide in power point using MATLAB code? I am using the code below but showing some error. clear
clc
%removed the clear all, close all, clc, as they are irrelevant here and can only cause problems
project_dir = pwd(); %new
% List all current folder contents ending with .png. Resulting names will
% appear in the order returned by the operating system.
files = dir( fullfile(project_dir, ‘*.png’)); %changed
% Create Common Object Model (COM) server so MATLAB can export data to
% PowerPoint
g = actxserver(‘powerpoint.application’);
% Open PowerPoint and make it visible
g.Visible = 1;
Presentation = g.Presentation;
% Prompt the user for the PowerPoint file to amend
[fn, pn] = uigetfile(‘*.pptx’, ‘Select PowerPoint File To Amend’);
filename = fullfile(pn, fn); %changed
Presentation = invoke(Presentation, ‘open’, filename);
% Get current number of slides
slide_count = get(Presentation.Slides, ‘Count’);
% Export all PNGs in the current directory to the PowerPoint file specified
% above. The following slides will be added to the END of the PowerPoint
% file. All slides will have a common title.
for i=1:length(files)
slide_count = int32(double(slide_count)+1);
slide = invoke(Presentation.Slides, ‘Add’, slide_count{i}, 11);
set(slide.Shapes.Title.Textframe.Textrange, ‘Text’, ‘SomeTitle’);
slidefile = fullfile(project_dir, files(i).name); %new
Image{i} = slide.Shapes.AddPicture(slidefile, ‘msoFalse’, ‘msoTrue’, 0, 80, 720, 440); %changed
end
% Save the amended PowerPoint presentation to the current directory
outfile = fullfile(project_dir, ‘DRAFT.pptx’); %new
Presentation.SaveAs(outfile); %changed
% Close PowerPoint as a COM automation server
g.Quit;
g.delete;
If i have 4 PNG images in a folder , how can i save (present) those in a single slide in power point using MATLAB code? I am using the code below but showing some error. image MATLAB Answers — New Questions
I need to draw a shape in matlab help me
Hi,I simulate something in matlab .For those wondering, this is the cross section of the rotor in the axial compressor.. I want to draw this picture in matlab same dimensions,same angles,and same shape.Additionally, I would like to have red dots at the corners of the angled areas where they intersect with the horizontal axes. I am open to your suggestions regarding this.Of course, dashed lines also need to be drawn. The dashed lines can be in blue. My drawing needs to start from the origin point.It needs to be added to the code I will post below and changed when I change the values related to the shape in the code.
% datas
rpm = 30000; % rev/min
Pti_Pte = 1.5; % compression ratio
efficiency = 0.9; % isentropic efficiency
mass_flow_rate = 1.6; % kg/s
r1s = 0.15; % m (stator distance from rotor axis)
aspect_ratio = 0.7; % geometrical ratio
P_amb = 101325; % Pa
T0 = 288.15; % K (environmental temperature)
gamma = 1.4; % specific heat ratio of air
cp = 1005; % J/(kg·K)
load_coefficient = 0.4;
% Calculating chord length and r2h from aspect ratio
chord = r1s / aspect_ratio; % chord = span / aspect_ratio
r2h = r1s – chord; % Shroud radius
% Step 1: Isenthalpic Relations and Tt2s Calculation
Tt1 = T0; % St2-St1 = 0
Tt2s = Tt1 * (Pti_Pte ^ ((gamma – 1) / gamma));
% Step 2: Tt2 calculations
Tt2 = Tt1 + (Tt2s – Tt1) / efficiency;
% Step 3: Enthalpy change (Delta H)
delta_h = cp * (Tt2 – Tt1); % J/kg
% Step 4: Umean calculation
U_mean = sqrt(delta_h / load_coefficient); % m/s
% Step 5: Axial velocity ve Mach Number
rho = P_amb / (287 * T0); % Density, ideal gas equation
V_axial = U_mean *0.5; % Axial hız
Mach = V_axial / sqrt(gamma * 287 * T0); % Mach sayısı
% Step 6: Calculation of Angles
V_theta2 = delta_h / U_mean; %
beta1 = atan(U_mean / V_axial)* (180 / pi); % Beta1 angle (degree)
beta2 = atan((U_mean – V_theta2) / V_axial) * (180 / pi); % Beta2 angle (degree)
% % Visualization of Results
fprintf(‘Tt2s: %.2f Kn’, Tt2s);
fprintf(‘Tt2: %.2f Kn’, Tt2);
fprintf(‘Delta H: %.2f J/kgn’, delta_h);
fprintf(‘Umean: %.2f m/sn’, U_mean);
fprintf(‘Mach Number: %.2fn’, Mach);
fprintf(‘V_axial: %.2f m/sn’, V_axial);
fprintf(‘V_theta2: %.2f m/sn’, V_theta2);
fprintf(‘Beta1: %.2f derecen’, beta1);
fprintf(‘Beta2: %.2f derecen’, beta2);Hi,I simulate something in matlab .For those wondering, this is the cross section of the rotor in the axial compressor.. I want to draw this picture in matlab same dimensions,same angles,and same shape.Additionally, I would like to have red dots at the corners of the angled areas where they intersect with the horizontal axes. I am open to your suggestions regarding this.Of course, dashed lines also need to be drawn. The dashed lines can be in blue. My drawing needs to start from the origin point.It needs to be added to the code I will post below and changed when I change the values related to the shape in the code.
% datas
rpm = 30000; % rev/min
Pti_Pte = 1.5; % compression ratio
efficiency = 0.9; % isentropic efficiency
mass_flow_rate = 1.6; % kg/s
r1s = 0.15; % m (stator distance from rotor axis)
aspect_ratio = 0.7; % geometrical ratio
P_amb = 101325; % Pa
T0 = 288.15; % K (environmental temperature)
gamma = 1.4; % specific heat ratio of air
cp = 1005; % J/(kg·K)
load_coefficient = 0.4;
% Calculating chord length and r2h from aspect ratio
chord = r1s / aspect_ratio; % chord = span / aspect_ratio
r2h = r1s – chord; % Shroud radius
% Step 1: Isenthalpic Relations and Tt2s Calculation
Tt1 = T0; % St2-St1 = 0
Tt2s = Tt1 * (Pti_Pte ^ ((gamma – 1) / gamma));
% Step 2: Tt2 calculations
Tt2 = Tt1 + (Tt2s – Tt1) / efficiency;
% Step 3: Enthalpy change (Delta H)
delta_h = cp * (Tt2 – Tt1); % J/kg
% Step 4: Umean calculation
U_mean = sqrt(delta_h / load_coefficient); % m/s
% Step 5: Axial velocity ve Mach Number
rho = P_amb / (287 * T0); % Density, ideal gas equation
V_axial = U_mean *0.5; % Axial hız
Mach = V_axial / sqrt(gamma * 287 * T0); % Mach sayısı
% Step 6: Calculation of Angles
V_theta2 = delta_h / U_mean; %
beta1 = atan(U_mean / V_axial)* (180 / pi); % Beta1 angle (degree)
beta2 = atan((U_mean – V_theta2) / V_axial) * (180 / pi); % Beta2 angle (degree)
% % Visualization of Results
fprintf(‘Tt2s: %.2f Kn’, Tt2s);
fprintf(‘Tt2: %.2f Kn’, Tt2);
fprintf(‘Delta H: %.2f J/kgn’, delta_h);
fprintf(‘Umean: %.2f m/sn’, U_mean);
fprintf(‘Mach Number: %.2fn’, Mach);
fprintf(‘V_axial: %.2f m/sn’, V_axial);
fprintf(‘V_theta2: %.2f m/sn’, V_theta2);
fprintf(‘Beta1: %.2f derecen’, beta1);
fprintf(‘Beta2: %.2f derecen’, beta2); Hi,I simulate something in matlab .For those wondering, this is the cross section of the rotor in the axial compressor.. I want to draw this picture in matlab same dimensions,same angles,and same shape.Additionally, I would like to have red dots at the corners of the angled areas where they intersect with the horizontal axes. I am open to your suggestions regarding this.Of course, dashed lines also need to be drawn. The dashed lines can be in blue. My drawing needs to start from the origin point.It needs to be added to the code I will post below and changed when I change the values related to the shape in the code.
% datas
rpm = 30000; % rev/min
Pti_Pte = 1.5; % compression ratio
efficiency = 0.9; % isentropic efficiency
mass_flow_rate = 1.6; % kg/s
r1s = 0.15; % m (stator distance from rotor axis)
aspect_ratio = 0.7; % geometrical ratio
P_amb = 101325; % Pa
T0 = 288.15; % K (environmental temperature)
gamma = 1.4; % specific heat ratio of air
cp = 1005; % J/(kg·K)
load_coefficient = 0.4;
% Calculating chord length and r2h from aspect ratio
chord = r1s / aspect_ratio; % chord = span / aspect_ratio
r2h = r1s – chord; % Shroud radius
% Step 1: Isenthalpic Relations and Tt2s Calculation
Tt1 = T0; % St2-St1 = 0
Tt2s = Tt1 * (Pti_Pte ^ ((gamma – 1) / gamma));
% Step 2: Tt2 calculations
Tt2 = Tt1 + (Tt2s – Tt1) / efficiency;
% Step 3: Enthalpy change (Delta H)
delta_h = cp * (Tt2 – Tt1); % J/kg
% Step 4: Umean calculation
U_mean = sqrt(delta_h / load_coefficient); % m/s
% Step 5: Axial velocity ve Mach Number
rho = P_amb / (287 * T0); % Density, ideal gas equation
V_axial = U_mean *0.5; % Axial hız
Mach = V_axial / sqrt(gamma * 287 * T0); % Mach sayısı
% Step 6: Calculation of Angles
V_theta2 = delta_h / U_mean; %
beta1 = atan(U_mean / V_axial)* (180 / pi); % Beta1 angle (degree)
beta2 = atan((U_mean – V_theta2) / V_axial) * (180 / pi); % Beta2 angle (degree)
% % Visualization of Results
fprintf(‘Tt2s: %.2f Kn’, Tt2s);
fprintf(‘Tt2: %.2f Kn’, Tt2);
fprintf(‘Delta H: %.2f J/kgn’, delta_h);
fprintf(‘Umean: %.2f m/sn’, U_mean);
fprintf(‘Mach Number: %.2fn’, Mach);
fprintf(‘V_axial: %.2f m/sn’, V_axial);
fprintf(‘V_theta2: %.2f m/sn’, V_theta2);
fprintf(‘Beta1: %.2f derecen’, beta1);
fprintf(‘Beta2: %.2f derecen’, beta2); figure, circle, gas turbine, compressor, rotor, color, variable MATLAB Answers — New Questions
Microsoft Word Check Box
HI,
Could someone offer a solution to use Matlab to read a word template and Tick Check Boxes such the ones illustrated below. ThanksHI,
Could someone offer a solution to use Matlab to read a word template and Tick Check Boxes such the ones illustrated below. Thanks HI,
Could someone offer a solution to use Matlab to read a word template and Tick Check Boxes such the ones illustrated below. Thanks word, check box MATLAB Answers — New Questions
command history with updates
How do I import my command history from a previous release, once I have installed a new one ?How do I import my command history from a previous release, once I have installed a new one ? How do I import my command history from a previous release, once I have installed a new one ? command history MATLAB Answers — New Questions
How to solve the error: Exception in thread “AWT-EventQueue-0” java.lang.IllegalArgumentException: Comparison method violates its general contract!
Hello,
I started receiving an error in matlab, which prevents me to see the command window but does not prevent the code from executing. I attached all the error message below. I do not know why this is happening but I guess it started after I used "save" commands in the editor. I basically load data into the editor and then preprocess the data so that I can use them later, and I save the new data for future computations. Since when I started saving data, this problem has been initiated. Now, I can’t stop matlab to produce this error every time I run any code. Can you please help me with this? I really appreciate that, thank you.
Original error:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeHi(Unknown Source)
at java.util.TimSort.mergeAt(Unknown Source)
at java.util.TimSort.mergeCollapse(Unknown Source)
at java.util.TimSort.sort(Unknown Source)
at java.util.Arrays.sort(Unknown Source)
at java.util.ArrayList.sort(Unknown Source)
at java.util.Collections.sort(Unknown Source)
at com.mathworks.widgets.grouptable.GroupingTableUtils.sortNonRecursively(GroupingTableUtils.java:296)
at com.mathworks.widgets.grouptable.RowListTransactionTarget.finishTransaction(RowListTransactionTarget.java:115)
at com.mathworks.widgets.grouptable.GroupingTableTransaction$1.run(GroupingTableTransaction.java:112)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
>>
Sincerely,
Irem VelibeyogluHello,
I started receiving an error in matlab, which prevents me to see the command window but does not prevent the code from executing. I attached all the error message below. I do not know why this is happening but I guess it started after I used "save" commands in the editor. I basically load data into the editor and then preprocess the data so that I can use them later, and I save the new data for future computations. Since when I started saving data, this problem has been initiated. Now, I can’t stop matlab to produce this error every time I run any code. Can you please help me with this? I really appreciate that, thank you.
Original error:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeHi(Unknown Source)
at java.util.TimSort.mergeAt(Unknown Source)
at java.util.TimSort.mergeCollapse(Unknown Source)
at java.util.TimSort.sort(Unknown Source)
at java.util.Arrays.sort(Unknown Source)
at java.util.ArrayList.sort(Unknown Source)
at java.util.Collections.sort(Unknown Source)
at com.mathworks.widgets.grouptable.GroupingTableUtils.sortNonRecursively(GroupingTableUtils.java:296)
at com.mathworks.widgets.grouptable.RowListTransactionTarget.finishTransaction(RowListTransactionTarget.java:115)
at com.mathworks.widgets.grouptable.GroupingTableTransaction$1.run(GroupingTableTransaction.java:112)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
>>
Sincerely,
Irem Velibeyoglu Hello,
I started receiving an error in matlab, which prevents me to see the command window but does not prevent the code from executing. I attached all the error message below. I do not know why this is happening but I guess it started after I used "save" commands in the editor. I basically load data into the editor and then preprocess the data so that I can use them later, and I save the new data for future computations. Since when I started saving data, this problem has been initiated. Now, I can’t stop matlab to produce this error every time I run any code. Can you please help me with this? I really appreciate that, thank you.
Original error:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeHi(Unknown Source)
at java.util.TimSort.mergeAt(Unknown Source)
at java.util.TimSort.mergeCollapse(Unknown Source)
at java.util.TimSort.sort(Unknown Source)
at java.util.Arrays.sort(Unknown Source)
at java.util.ArrayList.sort(Unknown Source)
at java.util.Collections.sort(Unknown Source)
at com.mathworks.widgets.grouptable.GroupingTableUtils.sortNonRecursively(GroupingTableUtils.java:296)
at com.mathworks.widgets.grouptable.RowListTransactionTarget.finishTransaction(RowListTransactionTarget.java:115)
at com.mathworks.widgets.grouptable.GroupingTableTransaction$1.run(GroupingTableTransaction.java:112)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
>>
Sincerely,
Irem Velibeyoglu java error MATLAB Answers — New Questions
Solving Unit Commitment using PSO
Dear Brother,
Anybody can help me to solve my unit commitment problem using PSO in Matlab? Here is below several probem I can’t solve it and I attach the example code as your consideration.
How determines ramp rates limit to solve UC using PSO
I get trouble to execute my code in 168 hour (a week), it’s always show me error. But when I run in maximum time 96 hours or less than it (Monday, Wednesday, Friday and Load sample) it’s okay.
Thank you
Best Regards,
RZLDear Brother,
Anybody can help me to solve my unit commitment problem using PSO in Matlab? Here is below several probem I can’t solve it and I attach the example code as your consideration.
How determines ramp rates limit to solve UC using PSO
I get trouble to execute my code in 168 hour (a week), it’s always show me error. But when I run in maximum time 96 hours or less than it (Monday, Wednesday, Friday and Load sample) it’s okay.
Thank you
Best Regards,
RZL Dear Brother,
Anybody can help me to solve my unit commitment problem using PSO in Matlab? Here is below several probem I can’t solve it and I attach the example code as your consideration.
How determines ramp rates limit to solve UC using PSO
I get trouble to execute my code in 168 hour (a week), it’s always show me error. But when I run in maximum time 96 hours or less than it (Monday, Wednesday, Friday and Load sample) it’s okay.
Thank you
Best Regards,
RZL matlab, uc, unit commitment, pso, optimization MATLAB Answers — New Questions
Radiation pattern code needed.
Can someone please help me to plot a radiation pattern of a H-plane horn antenna in matlab. I have tried so many times but it doesn’t work. Please share the code if somebody has it. thanks a bunch.Can someone please help me to plot a radiation pattern of a H-plane horn antenna in matlab. I have tried so many times but it doesn’t work. Please share the code if somebody has it. thanks a bunch. Can someone please help me to plot a radiation pattern of a H-plane horn antenna in matlab. I have tried so many times but it doesn’t work. Please share the code if somebody has it. thanks a bunch. horn antenna, radiation pattern. MATLAB Answers — New Questions
Hotkeys not working in matlab
Hi everyone! For some unknown reason, hotkeys do not work in the editor and command window. When I select the hotkey editor in the settings, for example Ctrl+W… I’m trying to set Ctrl+W, i press Ctrl+W but Matlab displays it as Ctrl+[]. So it’s like it can’t understand the symbol. Plz help. It’s impossible to work without Ctrl+Z, Ctrl+C, etc.
OS: Pop!_OS 22.04 LTS x86_64Hi everyone! For some unknown reason, hotkeys do not work in the editor and command window. When I select the hotkey editor in the settings, for example Ctrl+W… I’m trying to set Ctrl+W, i press Ctrl+W but Matlab displays it as Ctrl+[]. So it’s like it can’t understand the symbol. Plz help. It’s impossible to work without Ctrl+Z, Ctrl+C, etc.
OS: Pop!_OS 22.04 LTS x86_64 Hi everyone! For some unknown reason, hotkeys do not work in the editor and command window. When I select the hotkey editor in the settings, for example Ctrl+W… I’m trying to set Ctrl+W, i press Ctrl+W but Matlab displays it as Ctrl+[]. So it’s like it can’t understand the symbol. Plz help. It’s impossible to work without Ctrl+Z, Ctrl+C, etc.
OS: Pop!_OS 22.04 LTS x86_64 linux, keyboard, hotkeys MATLAB Answers — New Questions
how use categorical in uitable
VNAMES={‘On’,’Trading’,’L_S’,’Stat’,’PROVA’,’Cap’,’Perc’,’Draw_Sys’};
cat=categorical({‘Fil’;’Stat’});
VTYPES=[{‘logical’},{‘string’},{‘string’},{‘double’},{‘double’},{‘cat’},{‘double’},{‘logical’}];
T=table(‘Size’,[nrows,numel(VNAMES)],’VariableTypes’,VTYPES,’VariableNames’,VNAMES);
Error using table (line 310)
Specify variable types as a string array or a cell array of character
vectors, such as ["string", "datetime", "double"].
i try to use in vtypes : {‘cat’}..{cat}…{"cat"} but it give me an errorVNAMES={‘On’,’Trading’,’L_S’,’Stat’,’PROVA’,’Cap’,’Perc’,’Draw_Sys’};
cat=categorical({‘Fil’;’Stat’});
VTYPES=[{‘logical’},{‘string’},{‘string’},{‘double’},{‘double’},{‘cat’},{‘double’},{‘logical’}];
T=table(‘Size’,[nrows,numel(VNAMES)],’VariableTypes’,VTYPES,’VariableNames’,VNAMES);
Error using table (line 310)
Specify variable types as a string array or a cell array of character
vectors, such as ["string", "datetime", "double"].
i try to use in vtypes : {‘cat’}..{cat}…{"cat"} but it give me an error VNAMES={‘On’,’Trading’,’L_S’,’Stat’,’PROVA’,’Cap’,’Perc’,’Draw_Sys’};
cat=categorical({‘Fil’;’Stat’});
VTYPES=[{‘logical’},{‘string’},{‘string’},{‘double’},{‘double’},{‘cat’},{‘double’},{‘logical’}];
T=table(‘Size’,[nrows,numel(VNAMES)],’VariableTypes’,VTYPES,’VariableNames’,VNAMES);
Error using table (line 310)
Specify variable types as a string array or a cell array of character
vectors, such as ["string", "datetime", "double"].
i try to use in vtypes : {‘cat’}..{cat}…{"cat"} but it give me an error how use categorical in uitable MATLAB Answers — New Questions
Change size of input arguments without recompiling mex with codegen
I compiled a simple function with matlab coder. The function takes three input arguments: xvec is [nx,1], yvec is [ny,1] and zmat is [nx,ny]. All is good the first time I run the mex function, but if I subsequently change the size of one of the input arrays (say I change nx from nx=8 to nx=7), the function crashes. Of course I can compile again the code and it runs, but I really want to avoid recompilation every time I change the dimension of the inputs!
MWE here:
clear
clc
close all
nx = 8;
ny = 3;
xvec = linspace(0,1,nx)’;
yvec = linspace(0,1,ny)’;
zmat = xvec.^2+yvec’; % [nx,ny]
%size(zmat)
disp(‘Calling myfun…’)
res = myfun(xvec,yvec,zmat);
% MEX with codegen
disp(‘Compiling MEX…’)
cfg = coder.config(‘mex’);
cfg.GenerateReport = true;
codegen -config cfg myfun -args {xvec,yvec,zmat} -o myfun_mex
disp(‘Calling myfun_mex…’)
res_mex = myfun_mex(xvec,yvec,zmat);
err_mex = abs(res-res_mex)
and here is the function:
function res = myfun(x,y,z)
res = sum(x)+sum(y)+sum(sum(z));
end
First time, I compile and it runs OK. Then, if I set nx=7, it crashes with the following error message:
“`
Incorrect size for expression ‘x’: expected [8×1] but found [7×1].
Error in myfun_mex
Error in main (line 22)
res_mex = myfun_mex(xvec,yvec,zmat);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
“`
Any help is greatly appreciated, thanks!I compiled a simple function with matlab coder. The function takes three input arguments: xvec is [nx,1], yvec is [ny,1] and zmat is [nx,ny]. All is good the first time I run the mex function, but if I subsequently change the size of one of the input arrays (say I change nx from nx=8 to nx=7), the function crashes. Of course I can compile again the code and it runs, but I really want to avoid recompilation every time I change the dimension of the inputs!
MWE here:
clear
clc
close all
nx = 8;
ny = 3;
xvec = linspace(0,1,nx)’;
yvec = linspace(0,1,ny)’;
zmat = xvec.^2+yvec’; % [nx,ny]
%size(zmat)
disp(‘Calling myfun…’)
res = myfun(xvec,yvec,zmat);
% MEX with codegen
disp(‘Compiling MEX…’)
cfg = coder.config(‘mex’);
cfg.GenerateReport = true;
codegen -config cfg myfun -args {xvec,yvec,zmat} -o myfun_mex
disp(‘Calling myfun_mex…’)
res_mex = myfun_mex(xvec,yvec,zmat);
err_mex = abs(res-res_mex)
and here is the function:
function res = myfun(x,y,z)
res = sum(x)+sum(y)+sum(sum(z));
end
First time, I compile and it runs OK. Then, if I set nx=7, it crashes with the following error message:
“`
Incorrect size for expression ‘x’: expected [8×1] but found [7×1].
Error in myfun_mex
Error in main (line 22)
res_mex = myfun_mex(xvec,yvec,zmat);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
“`
Any help is greatly appreciated, thanks! I compiled a simple function with matlab coder. The function takes three input arguments: xvec is [nx,1], yvec is [ny,1] and zmat is [nx,ny]. All is good the first time I run the mex function, but if I subsequently change the size of one of the input arrays (say I change nx from nx=8 to nx=7), the function crashes. Of course I can compile again the code and it runs, but I really want to avoid recompilation every time I change the dimension of the inputs!
MWE here:
clear
clc
close all
nx = 8;
ny = 3;
xvec = linspace(0,1,nx)’;
yvec = linspace(0,1,ny)’;
zmat = xvec.^2+yvec’; % [nx,ny]
%size(zmat)
disp(‘Calling myfun…’)
res = myfun(xvec,yvec,zmat);
% MEX with codegen
disp(‘Compiling MEX…’)
cfg = coder.config(‘mex’);
cfg.GenerateReport = true;
codegen -config cfg myfun -args {xvec,yvec,zmat} -o myfun_mex
disp(‘Calling myfun_mex…’)
res_mex = myfun_mex(xvec,yvec,zmat);
err_mex = abs(res-res_mex)
and here is the function:
function res = myfun(x,y,z)
res = sum(x)+sum(y)+sum(sum(z));
end
First time, I compile and it runs OK. Then, if I set nx=7, it crashes with the following error message:
“`
Incorrect size for expression ‘x’: expected [8×1] but found [7×1].
Error in myfun_mex
Error in main (line 22)
res_mex = myfun_mex(xvec,yvec,zmat);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
“`
Any help is greatly appreciated, thanks! codegen, function, mex MATLAB Answers — New Questions
External mode option not showing on simulink matlab 2020a
I want to interface arduino with simulink in external mode but i didnt find external mode option in simulink.Please help me to find that ‘external mode’option in main menu.I want to interface arduino with simulink in external mode but i didnt find external mode option in simulink.Please help me to find that ‘external mode’option in main menu. I want to interface arduino with simulink in external mode but i didnt find external mode option in simulink.Please help me to find that ‘external mode’option in main menu. simulink, matlab MATLAB Answers — New Questions
Matlab no muestra el gráfico de mi codigo
Estoy usando matlab online y nunca he tenido problemas con las graficas ni codigo, todo me funcionaba perfecto, hace unos dias hice un codigo que me devuelve una grafica, pero hoy ejecute el mismo codigo sin ningun cambio y no me devuelve la grafica, solo me muestra el pnale de grafica pero en blanco
tengo el siguiente codigo:
close all
clear all
clc
% Duración y frecuencia de muestreo
duration = 5;
Fs = 44100;
t = linspace(0, duration, duration * Fs);
% crossfade con maximo de 1
crossfade = exponentialFunction(t, 1, 1);
% Señal generada aleatoriamente adicional para producir el efecto de crossfade
autoGeneratedSignal = cos(2 * pi * 1000 * t); % Ajusta la frecuencia y forma de la señal
% Aplicar crossfade a las dos señales
signal1 = autoGeneratedSignal .* crossfade(2, :);
signal2 = sin(2 * pi * 500 * t) .* crossfade(1, :); % Genera otra señal, puedes ajustar la frecuencia
% Sumar las señales para obtener el resultado del crossfade
result = signal2 + signal1;
% Visualizar el resultado
figure;
subplot(3, 1, 1);
plot(t, signal1, ‘LineWidth’, 2);
title(‘Señal Generada con Crossfade’);
subplot(3, 1, 2);
plot(t, signal2, ‘LineWidth’, 2);
title(‘Otra Señal con Crossfade’);
subplot(3, 1, 3);
plot(t, result, ‘LineWidth’, 2);
title(‘Resultado del Crossfade’);
% Reproducir el resultado
sound(result, Fs);
function y = exponentialFunction(t, decayRate, growthRate)
% Genera una función exponencial decreciente y creciente con un valor máximo de 1.
% Parámetros:
% t: Vector de tiempo
% decayRate: Tasa de decrecimiento exponencial (debe ser un número positivo)
% growthRate: Tasa de crecimiento exponencial (debe ser un número positivo)
% Asegúrate de que los parámetros sean válidos
if decayRate <= 0 || growthRate <= 0
error(‘Las tasas de decrecimiento y crecimiento deben ser números positivos.’);
end
% Genera las funciones exponenciales
decayFunction = exp(-decayRate * t);
growthFunction = 1 – exp(-growthRate * t);
% Normaliza las funciones para tener un valor máximo de 1
decayFunction = decayFunction / max(decayFunction);
growthFunction = growthFunction / max(growthFunction);
% Combina las funciones
y = [decayFunction; growthFunction];
endEstoy usando matlab online y nunca he tenido problemas con las graficas ni codigo, todo me funcionaba perfecto, hace unos dias hice un codigo que me devuelve una grafica, pero hoy ejecute el mismo codigo sin ningun cambio y no me devuelve la grafica, solo me muestra el pnale de grafica pero en blanco
tengo el siguiente codigo:
close all
clear all
clc
% Duración y frecuencia de muestreo
duration = 5;
Fs = 44100;
t = linspace(0, duration, duration * Fs);
% crossfade con maximo de 1
crossfade = exponentialFunction(t, 1, 1);
% Señal generada aleatoriamente adicional para producir el efecto de crossfade
autoGeneratedSignal = cos(2 * pi * 1000 * t); % Ajusta la frecuencia y forma de la señal
% Aplicar crossfade a las dos señales
signal1 = autoGeneratedSignal .* crossfade(2, :);
signal2 = sin(2 * pi * 500 * t) .* crossfade(1, :); % Genera otra señal, puedes ajustar la frecuencia
% Sumar las señales para obtener el resultado del crossfade
result = signal2 + signal1;
% Visualizar el resultado
figure;
subplot(3, 1, 1);
plot(t, signal1, ‘LineWidth’, 2);
title(‘Señal Generada con Crossfade’);
subplot(3, 1, 2);
plot(t, signal2, ‘LineWidth’, 2);
title(‘Otra Señal con Crossfade’);
subplot(3, 1, 3);
plot(t, result, ‘LineWidth’, 2);
title(‘Resultado del Crossfade’);
% Reproducir el resultado
sound(result, Fs);
function y = exponentialFunction(t, decayRate, growthRate)
% Genera una función exponencial decreciente y creciente con un valor máximo de 1.
% Parámetros:
% t: Vector de tiempo
% decayRate: Tasa de decrecimiento exponencial (debe ser un número positivo)
% growthRate: Tasa de crecimiento exponencial (debe ser un número positivo)
% Asegúrate de que los parámetros sean válidos
if decayRate <= 0 || growthRate <= 0
error(‘Las tasas de decrecimiento y crecimiento deben ser números positivos.’);
end
% Genera las funciones exponenciales
decayFunction = exp(-decayRate * t);
growthFunction = 1 – exp(-growthRate * t);
% Normaliza las funciones para tener un valor máximo de 1
decayFunction = decayFunction / max(decayFunction);
growthFunction = growthFunction / max(growthFunction);
% Combina las funciones
y = [decayFunction; growthFunction];
end Estoy usando matlab online y nunca he tenido problemas con las graficas ni codigo, todo me funcionaba perfecto, hace unos dias hice un codigo que me devuelve una grafica, pero hoy ejecute el mismo codigo sin ningun cambio y no me devuelve la grafica, solo me muestra el pnale de grafica pero en blanco
tengo el siguiente codigo:
close all
clear all
clc
% Duración y frecuencia de muestreo
duration = 5;
Fs = 44100;
t = linspace(0, duration, duration * Fs);
% crossfade con maximo de 1
crossfade = exponentialFunction(t, 1, 1);
% Señal generada aleatoriamente adicional para producir el efecto de crossfade
autoGeneratedSignal = cos(2 * pi * 1000 * t); % Ajusta la frecuencia y forma de la señal
% Aplicar crossfade a las dos señales
signal1 = autoGeneratedSignal .* crossfade(2, :);
signal2 = sin(2 * pi * 500 * t) .* crossfade(1, :); % Genera otra señal, puedes ajustar la frecuencia
% Sumar las señales para obtener el resultado del crossfade
result = signal2 + signal1;
% Visualizar el resultado
figure;
subplot(3, 1, 1);
plot(t, signal1, ‘LineWidth’, 2);
title(‘Señal Generada con Crossfade’);
subplot(3, 1, 2);
plot(t, signal2, ‘LineWidth’, 2);
title(‘Otra Señal con Crossfade’);
subplot(3, 1, 3);
plot(t, result, ‘LineWidth’, 2);
title(‘Resultado del Crossfade’);
% Reproducir el resultado
sound(result, Fs);
function y = exponentialFunction(t, decayRate, growthRate)
% Genera una función exponencial decreciente y creciente con un valor máximo de 1.
% Parámetros:
% t: Vector de tiempo
% decayRate: Tasa de decrecimiento exponencial (debe ser un número positivo)
% growthRate: Tasa de crecimiento exponencial (debe ser un número positivo)
% Asegúrate de que los parámetros sean válidos
if decayRate <= 0 || growthRate <= 0
error(‘Las tasas de decrecimiento y crecimiento deben ser números positivos.’);
end
% Genera las funciones exponenciales
decayFunction = exp(-decayRate * t);
growthFunction = 1 – exp(-growthRate * t);
% Normaliza las funciones para tener un valor máximo de 1
decayFunction = decayFunction / max(decayFunction);
growthFunction = growthFunction / max(growthFunction);
% Combina las funciones
y = [decayFunction; growthFunction];
end matlab online MATLAB Answers — New Questions
Vehicle Dynamics 3DOF Single Track Block doesn’t seem to include drag equations.
For the Vehicle Body 3 DOF block in the Vehicle Dynamics Blockset, I’ve configured it to run in single track mode. The documentation includes equations for drag forces under the dual track section, but not the single track section, which led me to believe that the drag forces are only relevant for the dual track block.
This does not seem to be the case, as I’m observing the drag forces in the output of the single track block to be nonzero. It makes sense that drag would be accounted for in both single track and dual track modes, but why then are the drag forces only described in the dual track equations?
Furthermore, the single track documentation does mention drag forces, saying that external forces = drag forces + input forces:
But then when I observe the external body forces as output by the block, they are always 0 despite the drag forces being nonzero. Seems like there might be a term overload with "external forces" referring both to the external input forces as well as the drag + input combined force.
External force input:
What I thought would be the computed external force output (drag + input forces), but is always 0 when input force is 0:For the Vehicle Body 3 DOF block in the Vehicle Dynamics Blockset, I’ve configured it to run in single track mode. The documentation includes equations for drag forces under the dual track section, but not the single track section, which led me to believe that the drag forces are only relevant for the dual track block.
This does not seem to be the case, as I’m observing the drag forces in the output of the single track block to be nonzero. It makes sense that drag would be accounted for in both single track and dual track modes, but why then are the drag forces only described in the dual track equations?
Furthermore, the single track documentation does mention drag forces, saying that external forces = drag forces + input forces:
But then when I observe the external body forces as output by the block, they are always 0 despite the drag forces being nonzero. Seems like there might be a term overload with "external forces" referring both to the external input forces as well as the drag + input combined force.
External force input:
What I thought would be the computed external force output (drag + input forces), but is always 0 when input force is 0: For the Vehicle Body 3 DOF block in the Vehicle Dynamics Blockset, I’ve configured it to run in single track mode. The documentation includes equations for drag forces under the dual track section, but not the single track section, which led me to believe that the drag forces are only relevant for the dual track block.
This does not seem to be the case, as I’m observing the drag forces in the output of the single track block to be nonzero. It makes sense that drag would be accounted for in both single track and dual track modes, but why then are the drag forces only described in the dual track equations?
Furthermore, the single track documentation does mention drag forces, saying that external forces = drag forces + input forces:
But then when I observe the external body forces as output by the block, they are always 0 despite the drag forces being nonzero. Seems like there might be a term overload with "external forces" referring both to the external input forces as well as the drag + input combined force.
External force input:
What I thought would be the computed external force output (drag + input forces), but is always 0 when input force is 0: simulink, vehicle dynamics MATLAB Answers — New Questions
Calculating UACI, NPCR for 2 images
Presently I have a problem in implementing the UACI and PSNR code for 2 images which are respectively Original & Cipher Images. I need the code for calculating it……
What would the Code? I don’t have much idea about it..
Do I need to find UACI between 2 images or only 1 image will be sufficientPresently I have a problem in implementing the UACI and PSNR code for 2 images which are respectively Original & Cipher Images. I need the code for calculating it……
What would the Code? I don’t have much idea about it..
Do I need to find UACI between 2 images or only 1 image will be sufficient Presently I have a problem in implementing the UACI and PSNR code for 2 images which are respectively Original & Cipher Images. I need the code for calculating it……
What would the Code? I don’t have much idea about it..
Do I need to find UACI between 2 images or only 1 image will be sufficient uaci, psnr calculation MATLAB Answers — New Questions
Help with MATLAB symbolic toolbox
Hi there everyone,
I need some help with using the MATLAB symbolic tool box.
I have some symbolic expressions to manipulate and I am getting quite frustrated.
I have the paticular solution to a differential equation and need to find the coefficients C1 and C2.
% Set up symbolic variables
syms t C1 C2
% Set up parameters
K = 2.2167e+06;
M = 45.96;
wn = sqrt(K/M)
c = 0.5
% set up quadratic terms
a = 1
b = 2*c*wn
c = wn^2
% Solve for u
u1 = (-b + sqrt(b^2 – 4*a*c))/2
u2 = (-b – sqrt(b^2 – 4*a*c))/2
% Particalular solution to differential equation
yp = vpa(exp(-43.1357*t)*(C1*cos(74.7132*t) + C2*sin(74.7132*t)) == 0,4)
% The first derivitive of yp
dyp = vpa(diff(yp),4)
% Find the value of C1 interm of C2
C1 = vpa(solve(yp, C1),4)
% Sub C1 into equation dyp to have an expression in terms of C2 alone
eq = vpa(subs(dyp,C2,C1),4)
As you can see I obtain the value of C1 in terms of C2. I then want to plug this into equation "dyp". However, when I run the code for "eq", C1 is still in the expression. The expression should contain just C2’s, and this is really frustrating. If equation "eq" contains just C2 values I can then solve for C2 – I hope this makes sense.
Is there a way around this. I have not very good at plug and chucking with long and messy equatons, so I am hoping MATLAB can help me out.
Thanks in advance,
ScottHi there everyone,
I need some help with using the MATLAB symbolic tool box.
I have some symbolic expressions to manipulate and I am getting quite frustrated.
I have the paticular solution to a differential equation and need to find the coefficients C1 and C2.
% Set up symbolic variables
syms t C1 C2
% Set up parameters
K = 2.2167e+06;
M = 45.96;
wn = sqrt(K/M)
c = 0.5
% set up quadratic terms
a = 1
b = 2*c*wn
c = wn^2
% Solve for u
u1 = (-b + sqrt(b^2 – 4*a*c))/2
u2 = (-b – sqrt(b^2 – 4*a*c))/2
% Particalular solution to differential equation
yp = vpa(exp(-43.1357*t)*(C1*cos(74.7132*t) + C2*sin(74.7132*t)) == 0,4)
% The first derivitive of yp
dyp = vpa(diff(yp),4)
% Find the value of C1 interm of C2
C1 = vpa(solve(yp, C1),4)
% Sub C1 into equation dyp to have an expression in terms of C2 alone
eq = vpa(subs(dyp,C2,C1),4)
As you can see I obtain the value of C1 in terms of C2. I then want to plug this into equation "dyp". However, when I run the code for "eq", C1 is still in the expression. The expression should contain just C2’s, and this is really frustrating. If equation "eq" contains just C2 values I can then solve for C2 – I hope this makes sense.
Is there a way around this. I have not very good at plug and chucking with long and messy equatons, so I am hoping MATLAB can help me out.
Thanks in advance,
Scott Hi there everyone,
I need some help with using the MATLAB symbolic tool box.
I have some symbolic expressions to manipulate and I am getting quite frustrated.
I have the paticular solution to a differential equation and need to find the coefficients C1 and C2.
% Set up symbolic variables
syms t C1 C2
% Set up parameters
K = 2.2167e+06;
M = 45.96;
wn = sqrt(K/M)
c = 0.5
% set up quadratic terms
a = 1
b = 2*c*wn
c = wn^2
% Solve for u
u1 = (-b + sqrt(b^2 – 4*a*c))/2
u2 = (-b – sqrt(b^2 – 4*a*c))/2
% Particalular solution to differential equation
yp = vpa(exp(-43.1357*t)*(C1*cos(74.7132*t) + C2*sin(74.7132*t)) == 0,4)
% The first derivitive of yp
dyp = vpa(diff(yp),4)
% Find the value of C1 interm of C2
C1 = vpa(solve(yp, C1),4)
% Sub C1 into equation dyp to have an expression in terms of C2 alone
eq = vpa(subs(dyp,C2,C1),4)
As you can see I obtain the value of C1 in terms of C2. I then want to plug this into equation "dyp". However, when I run the code for "eq", C1 is still in the expression. The expression should contain just C2’s, and this is really frustrating. If equation "eq" contains just C2 values I can then solve for C2 – I hope this makes sense.
Is there a way around this. I have not very good at plug and chucking with long and messy equatons, so I am hoping MATLAB can help me out.
Thanks in advance,
Scott symbolic MATLAB Answers — New Questions
error: Function definition is misplaced or improperly nested error?
I am defining a nested function (bicomp1) inside a function (biaxialcomp) whose output is to be minimised using the fmincon optimization function, but I get an error that this function is misplaced or improperly nested. What could be the problem with it?
function [Mux, Muy] = biaxialcomp(c,app,gc,gs,bar,n,i)
th = [10 20 30 40 50 60 70 80];
Mux = zeros(1,8);
Muy = zeros(1,8);
for iv = 1:8
% first potential scenario
if app.b*tand(th(iv)) < app.t
tt = app.b*sind(th(iv))+app.t*cosd(th(iv));
c_opt = fmincon(@bicomp1,c,[],[],[],[],0,tt);
function obj = bicomp1(c)
a = 0.8*c;
Xna = a/sind(th(iv));
fcu = 0.67*app.Fcu/gc;
…I am defining a nested function (bicomp1) inside a function (biaxialcomp) whose output is to be minimised using the fmincon optimization function, but I get an error that this function is misplaced or improperly nested. What could be the problem with it?
function [Mux, Muy] = biaxialcomp(c,app,gc,gs,bar,n,i)
th = [10 20 30 40 50 60 70 80];
Mux = zeros(1,8);
Muy = zeros(1,8);
for iv = 1:8
% first potential scenario
if app.b*tand(th(iv)) < app.t
tt = app.b*sind(th(iv))+app.t*cosd(th(iv));
c_opt = fmincon(@bicomp1,c,[],[],[],[],0,tt);
function obj = bicomp1(c)
a = 0.8*c;
Xna = a/sind(th(iv));
fcu = 0.67*app.Fcu/gc;
… I am defining a nested function (bicomp1) inside a function (biaxialcomp) whose output is to be minimised using the fmincon optimization function, but I get an error that this function is misplaced or improperly nested. What could be the problem with it?
function [Mux, Muy] = biaxialcomp(c,app,gc,gs,bar,n,i)
th = [10 20 30 40 50 60 70 80];
Mux = zeros(1,8);
Muy = zeros(1,8);
for iv = 1:8
% first potential scenario
if app.b*tand(th(iv)) < app.t
tt = app.b*sind(th(iv))+app.t*cosd(th(iv));
c_opt = fmincon(@bicomp1,c,[],[],[],[],0,tt);
function obj = bicomp1(c)
a = 0.8*c;
Xna = a/sind(th(iv));
fcu = 0.67*app.Fcu/gc;
… functions MATLAB Answers — New Questions
Viscircles. Example doesn’t work
I try to understand function Viscircles. But i can’t do it. I can’t to launch the example Clear Axes Before Plotting Circles. Where i can wrong?
figure
colors = {‘b’,’r’,’g’,’y’,’k’};
for k = 1:5
% Create 5 random circles to display,
X = rand(5,1);
Y = rand(5,1);
centers = [X Y];
radii = 0.1*rand(5,1);
% Clear the axes.
cla
% Fix the axis limits.
xlim([-0.1 1.1])
ylim([-0.1 1.1])
% Set the axis aspect ratio to 1:1.
axis square
% Set a title.
title([‘k = ‘ num2str(k)])
% Display the circles.
viscircles(centers,radii,’Color’,colors{k});
%% Error using viscircles>parseInputs (line 175) Unknown input string: Color.
%% Error in viscircles (line 67) [ax, centers, radii, options] = parseInputs(varargin{:});
% Pause for 1 second.
pause(1)
endI try to understand function Viscircles. But i can’t do it. I can’t to launch the example Clear Axes Before Plotting Circles. Where i can wrong?
figure
colors = {‘b’,’r’,’g’,’y’,’k’};
for k = 1:5
% Create 5 random circles to display,
X = rand(5,1);
Y = rand(5,1);
centers = [X Y];
radii = 0.1*rand(5,1);
% Clear the axes.
cla
% Fix the axis limits.
xlim([-0.1 1.1])
ylim([-0.1 1.1])
% Set the axis aspect ratio to 1:1.
axis square
% Set a title.
title([‘k = ‘ num2str(k)])
% Display the circles.
viscircles(centers,radii,’Color’,colors{k});
%% Error using viscircles>parseInputs (line 175) Unknown input string: Color.
%% Error in viscircles (line 67) [ax, centers, radii, options] = parseInputs(varargin{:});
% Pause for 1 second.
pause(1)
end I try to understand function Viscircles. But i can’t do it. I can’t to launch the example Clear Axes Before Plotting Circles. Where i can wrong?
figure
colors = {‘b’,’r’,’g’,’y’,’k’};
for k = 1:5
% Create 5 random circles to display,
X = rand(5,1);
Y = rand(5,1);
centers = [X Y];
radii = 0.1*rand(5,1);
% Clear the axes.
cla
% Fix the axis limits.
xlim([-0.1 1.1])
ylim([-0.1 1.1])
% Set the axis aspect ratio to 1:1.
axis square
% Set a title.
title([‘k = ‘ num2str(k)])
% Display the circles.
viscircles(centers,radii,’Color’,colors{k});
%% Error using viscircles>parseInputs (line 175) Unknown input string: Color.
%% Error in viscircles (line 67) [ax, centers, radii, options] = parseInputs(varargin{:});
% Pause for 1 second.
pause(1)
end viscircles MATLAB Answers — New Questions