Category: Matlab
Category Archives: Matlab
How to interpolate data as stairs
I have a struct (lets call it Turbine State) with both time and value data. The issue is there aren’t enough data points captured with the range I want, so MATLAB intertpolates the missing data linearly between points.
i.e. shortly beore 14:10 the ‘state’ is 12 but this should remain 12 until it isn’t anymore. so the state should remain 12 before just after 14:30 when it drops to -1. How do i make this a ‘stairs’ representation and not a liner interpolation?
Thanks :)I have a struct (lets call it Turbine State) with both time and value data. The issue is there aren’t enough data points captured with the range I want, so MATLAB intertpolates the missing data linearly between points.
i.e. shortly beore 14:10 the ‘state’ is 12 but this should remain 12 until it isn’t anymore. so the state should remain 12 before just after 14:30 when it drops to -1. How do i make this a ‘stairs’ representation and not a liner interpolation?
Thanks 🙂 I have a struct (lets call it Turbine State) with both time and value data. The issue is there aren’t enough data points captured with the range I want, so MATLAB intertpolates the missing data linearly between points.
i.e. shortly beore 14:10 the ‘state’ is 12 but this should remain 12 until it isn’t anymore. so the state should remain 12 before just after 14:30 when it drops to -1. How do i make this a ‘stairs’ representation and not a liner interpolation?
Thanks 🙂 matlab, plot, plotting, interpolation MATLAB Answers — New Questions
How to block a drawnow from executing callbacks?
Mathworks has recklessly put a drawnow inside of its asynciolib for hardware read and writes:
toolboxsharedasynciolib+matlabshared+asyncio+internalStream.m Line 184: drawnow(‘limitrate’);
This will then execute callbacks in the middle of data transfer! I could remove those lines of code for every Matlab install, but if an update restores the code then I have a dangerous bug. Is there a way I can temporarily pause the event queue from executing callbacks?
The following function CallbackTest has a 10 second main loop which should not be interrupted with the press of a button. However if TCPIP commands are executed in the loop then a hidden drawnow is invoked and the button callback will be processed.
function CallbackTest(Do_TCPIP)
% Test to see if TCPIP reads evaluate callbacks.
% There is a 10s main loop which the button callback should not interrupt.
% The main loop will not be interrupted when Do_TCPIP is 0.
% However when Do_TCPIP is 1 then it will be interrupted.
%Initialize figure and button
hFigure=uifigure();
uibutton(hFigure,ButtonPushedFcn=@ACallBack);
%Initialize TCPIP
echotcpip("on",4000);
t = tcpclient("localhost",4000);
configureTerminator(t,"CR");
waitfor(hFigure,’FigureViewReady’)
%10 second main loop which should not be interrupted because there is no drawnow, figure, pause, or waitfor command
n=0;
while n < 20
if Do_TCPIP
writeline(t,"loop");
readline(t);
end
n=n+1;
java.lang.Thread.sleep(500);
end
% Wrap up
echotcpip("off");
delete(hFigure)
fprintf(‘Done!n’);
end
function ACallBack(~,~)
fprintf(‘Main loop interrupted.n’);
endMathworks has recklessly put a drawnow inside of its asynciolib for hardware read and writes:
toolboxsharedasynciolib+matlabshared+asyncio+internalStream.m Line 184: drawnow(‘limitrate’);
This will then execute callbacks in the middle of data transfer! I could remove those lines of code for every Matlab install, but if an update restores the code then I have a dangerous bug. Is there a way I can temporarily pause the event queue from executing callbacks?
The following function CallbackTest has a 10 second main loop which should not be interrupted with the press of a button. However if TCPIP commands are executed in the loop then a hidden drawnow is invoked and the button callback will be processed.
function CallbackTest(Do_TCPIP)
% Test to see if TCPIP reads evaluate callbacks.
% There is a 10s main loop which the button callback should not interrupt.
% The main loop will not be interrupted when Do_TCPIP is 0.
% However when Do_TCPIP is 1 then it will be interrupted.
%Initialize figure and button
hFigure=uifigure();
uibutton(hFigure,ButtonPushedFcn=@ACallBack);
%Initialize TCPIP
echotcpip("on",4000);
t = tcpclient("localhost",4000);
configureTerminator(t,"CR");
waitfor(hFigure,’FigureViewReady’)
%10 second main loop which should not be interrupted because there is no drawnow, figure, pause, or waitfor command
n=0;
while n < 20
if Do_TCPIP
writeline(t,"loop");
readline(t);
end
n=n+1;
java.lang.Thread.sleep(500);
end
% Wrap up
echotcpip("off");
delete(hFigure)
fprintf(‘Done!n’);
end
function ACallBack(~,~)
fprintf(‘Main loop interrupted.n’);
end Mathworks has recklessly put a drawnow inside of its asynciolib for hardware read and writes:
toolboxsharedasynciolib+matlabshared+asyncio+internalStream.m Line 184: drawnow(‘limitrate’);
This will then execute callbacks in the middle of data transfer! I could remove those lines of code for every Matlab install, but if an update restores the code then I have a dangerous bug. Is there a way I can temporarily pause the event queue from executing callbacks?
The following function CallbackTest has a 10 second main loop which should not be interrupted with the press of a button. However if TCPIP commands are executed in the loop then a hidden drawnow is invoked and the button callback will be processed.
function CallbackTest(Do_TCPIP)
% Test to see if TCPIP reads evaluate callbacks.
% There is a 10s main loop which the button callback should not interrupt.
% The main loop will not be interrupted when Do_TCPIP is 0.
% However when Do_TCPIP is 1 then it will be interrupted.
%Initialize figure and button
hFigure=uifigure();
uibutton(hFigure,ButtonPushedFcn=@ACallBack);
%Initialize TCPIP
echotcpip("on",4000);
t = tcpclient("localhost",4000);
configureTerminator(t,"CR");
waitfor(hFigure,’FigureViewReady’)
%10 second main loop which should not be interrupted because there is no drawnow, figure, pause, or waitfor command
n=0;
while n < 20
if Do_TCPIP
writeline(t,"loop");
readline(t);
end
n=n+1;
java.lang.Thread.sleep(500);
end
% Wrap up
echotcpip("off");
delete(hFigure)
fprintf(‘Done!n’);
end
function ACallBack(~,~)
fprintf(‘Main loop interrupted.n’);
end drawnow, tcpip, hardware, callbacks MATLAB Answers — New Questions
P-H diagram in Axes tool of App designer
Hi,
I want to reproduce the p-h diagram in App designer usin the ‘Axes’ component during the simulation of my simulink refrigeration model. My model has sensors elements from Simscape which provide the respective outputs of pressure and enthalpy necessary for the p-h diagram. However, I do not know how the code should be in UIAxes callback in order to take the live data from the sensors and then plot it in the ‘Axes’ component.
does anybody know how to do it?
Thanks in advance for your comments!Hi,
I want to reproduce the p-h diagram in App designer usin the ‘Axes’ component during the simulation of my simulink refrigeration model. My model has sensors elements from Simscape which provide the respective outputs of pressure and enthalpy necessary for the p-h diagram. However, I do not know how the code should be in UIAxes callback in order to take the live data from the sensors and then plot it in the ‘Axes’ component.
does anybody know how to do it?
Thanks in advance for your comments! Hi,
I want to reproduce the p-h diagram in App designer usin the ‘Axes’ component during the simulation of my simulink refrigeration model. My model has sensors elements from Simscape which provide the respective outputs of pressure and enthalpy necessary for the p-h diagram. However, I do not know how the code should be in UIAxes callback in order to take the live data from the sensors and then plot it in the ‘Axes’ component.
does anybody know how to do it?
Thanks in advance for your comments! app designer, axes tool, p-h diafram MATLAB Answers — New Questions
How to vary angles at constant rate in a kinematics problem?
o2 = [0, 0, 0]; % Origin
ain = [26,0,0]; % Initial vector
input_axis = [0,1,0]; % Axis of rotation (z-axis)
theta1 = deg2rad(157.5); % Angle of rotation in radians
% Rotation matrix function
rot_matrix = @(axis, theta) cos(theta) * eye(3) + …
sin(theta) * [0, -axis(3), axis(2); axis(3), 0, -axis(1); -axis(2), axis(1), 0] + …
(1 – cos(theta)) * (axis’ * axis);
% Compute the rotated vector
a_rotated = rot_matrix(input_axis, theta1) * (ain’ – o2′) + o2′;
% Transpose to row vector for display
a_rotated = a_rotated’;
a_final=a_rotated;
bin=[29.5,46,0];
o4=[13.5,46,0];
output_axis=[0,1,0];
theta2= deg2rad(105);
b1_rotated = rot_matrix(output_axis, theta2) * (bin’ – o4′) + o4′;
b1_final=b1_rotated’;
u3=[0,0,1];
c1=[125,0,0];
% Compute the rotated vector in terms of phi
syms phi;
rot_matrix_phi = rot_matrix(u3, phi);
c1_afinal_rotated = rot_matrix_phi * (c1 – a_final)’+a_final’ ;
c1_afinal_rotated = c1_afinal_rotated’; % Transpose to row vector for display
o4o2=o4-o2;
%disp(o4o2);
coupler=(c1_afinal_rotated-b1_final);
% Define the initial rotated components of the coupler
syms phi;
coupler = subs(coupler, conj(phi), phi);
%disp(‘Coupler vector without conjugate:’);
disp(coupler);
% Parametric substitution
syms t;
cos_phi = (1 – t^2) / (1 + t^2);
sin_phi = 2 * t / (1 + t^2);
% Substitute parametric forms into coupler components
coupler_parametric = subs(coupler, [cos(phi), sin(phi)], [cos_phi, sin_phi]);
% Display the parametric coupler
disp(‘Parametric form of coupler:’);
disp(coupler_parametric);
syms targetvalue % it might be 3.5 …
normsq = expand(sum(coupler_parametric.^2) – targetvalue^2);
normpoly = simplify(normsq*(t^2+1)^2);
vpa(expand(normpoly),4);
tsolve = solve(normpoly,t,’maxdegree’,4,’returnconditions’,true);
h=vpa(subs(tsolve.t,targetvalue, 106));
%disp(h);
real_solutions = h(imag(h) == 0);
disp(‘Real roots:’);
disp(real_solutions);
% Convert real values of t to angles using angle = 2 * atan(t)
angles_rad = 2 * atan(real_solutions);
angles_deg = rad2deg(angles_rad);
% Display angles in degrees
disp(‘Angles in degrees before adjustment:’);
disp(angles_deg);
phi=double(angles_rad(1));
p=double(angles_deg(1));
c1_position = double(rot_matrix(u3, phi) * (c1′ – a_final’) + a_final’);
p=(c1_position’-a_final)’;
disp(p’);
disp(p(2)/norm(c1_position’-a_final));
final_angle_phi=acosd(p(2)/norm(c1_position’-a_final)); % angle with y axis
disp(final_angle_phi) ;
disp(norm(c1_position’-b1_final));
disp(norm(a_rotated-o2));
%% in this code i want to change theta1 at rate of 90deg/sec and theta2 at rate of 60 deg/sec varying from 0 to 360 deg and want to calculate corresponding value of final_angle_phi with the y axis
%please help someoneo2 = [0, 0, 0]; % Origin
ain = [26,0,0]; % Initial vector
input_axis = [0,1,0]; % Axis of rotation (z-axis)
theta1 = deg2rad(157.5); % Angle of rotation in radians
% Rotation matrix function
rot_matrix = @(axis, theta) cos(theta) * eye(3) + …
sin(theta) * [0, -axis(3), axis(2); axis(3), 0, -axis(1); -axis(2), axis(1), 0] + …
(1 – cos(theta)) * (axis’ * axis);
% Compute the rotated vector
a_rotated = rot_matrix(input_axis, theta1) * (ain’ – o2′) + o2′;
% Transpose to row vector for display
a_rotated = a_rotated’;
a_final=a_rotated;
bin=[29.5,46,0];
o4=[13.5,46,0];
output_axis=[0,1,0];
theta2= deg2rad(105);
b1_rotated = rot_matrix(output_axis, theta2) * (bin’ – o4′) + o4′;
b1_final=b1_rotated’;
u3=[0,0,1];
c1=[125,0,0];
% Compute the rotated vector in terms of phi
syms phi;
rot_matrix_phi = rot_matrix(u3, phi);
c1_afinal_rotated = rot_matrix_phi * (c1 – a_final)’+a_final’ ;
c1_afinal_rotated = c1_afinal_rotated’; % Transpose to row vector for display
o4o2=o4-o2;
%disp(o4o2);
coupler=(c1_afinal_rotated-b1_final);
% Define the initial rotated components of the coupler
syms phi;
coupler = subs(coupler, conj(phi), phi);
%disp(‘Coupler vector without conjugate:’);
disp(coupler);
% Parametric substitution
syms t;
cos_phi = (1 – t^2) / (1 + t^2);
sin_phi = 2 * t / (1 + t^2);
% Substitute parametric forms into coupler components
coupler_parametric = subs(coupler, [cos(phi), sin(phi)], [cos_phi, sin_phi]);
% Display the parametric coupler
disp(‘Parametric form of coupler:’);
disp(coupler_parametric);
syms targetvalue % it might be 3.5 …
normsq = expand(sum(coupler_parametric.^2) – targetvalue^2);
normpoly = simplify(normsq*(t^2+1)^2);
vpa(expand(normpoly),4);
tsolve = solve(normpoly,t,’maxdegree’,4,’returnconditions’,true);
h=vpa(subs(tsolve.t,targetvalue, 106));
%disp(h);
real_solutions = h(imag(h) == 0);
disp(‘Real roots:’);
disp(real_solutions);
% Convert real values of t to angles using angle = 2 * atan(t)
angles_rad = 2 * atan(real_solutions);
angles_deg = rad2deg(angles_rad);
% Display angles in degrees
disp(‘Angles in degrees before adjustment:’);
disp(angles_deg);
phi=double(angles_rad(1));
p=double(angles_deg(1));
c1_position = double(rot_matrix(u3, phi) * (c1′ – a_final’) + a_final’);
p=(c1_position’-a_final)’;
disp(p’);
disp(p(2)/norm(c1_position’-a_final));
final_angle_phi=acosd(p(2)/norm(c1_position’-a_final)); % angle with y axis
disp(final_angle_phi) ;
disp(norm(c1_position’-b1_final));
disp(norm(a_rotated-o2));
%% in this code i want to change theta1 at rate of 90deg/sec and theta2 at rate of 60 deg/sec varying from 0 to 360 deg and want to calculate corresponding value of final_angle_phi with the y axis
%please help someone o2 = [0, 0, 0]; % Origin
ain = [26,0,0]; % Initial vector
input_axis = [0,1,0]; % Axis of rotation (z-axis)
theta1 = deg2rad(157.5); % Angle of rotation in radians
% Rotation matrix function
rot_matrix = @(axis, theta) cos(theta) * eye(3) + …
sin(theta) * [0, -axis(3), axis(2); axis(3), 0, -axis(1); -axis(2), axis(1), 0] + …
(1 – cos(theta)) * (axis’ * axis);
% Compute the rotated vector
a_rotated = rot_matrix(input_axis, theta1) * (ain’ – o2′) + o2′;
% Transpose to row vector for display
a_rotated = a_rotated’;
a_final=a_rotated;
bin=[29.5,46,0];
o4=[13.5,46,0];
output_axis=[0,1,0];
theta2= deg2rad(105);
b1_rotated = rot_matrix(output_axis, theta2) * (bin’ – o4′) + o4′;
b1_final=b1_rotated’;
u3=[0,0,1];
c1=[125,0,0];
% Compute the rotated vector in terms of phi
syms phi;
rot_matrix_phi = rot_matrix(u3, phi);
c1_afinal_rotated = rot_matrix_phi * (c1 – a_final)’+a_final’ ;
c1_afinal_rotated = c1_afinal_rotated’; % Transpose to row vector for display
o4o2=o4-o2;
%disp(o4o2);
coupler=(c1_afinal_rotated-b1_final);
% Define the initial rotated components of the coupler
syms phi;
coupler = subs(coupler, conj(phi), phi);
%disp(‘Coupler vector without conjugate:’);
disp(coupler);
% Parametric substitution
syms t;
cos_phi = (1 – t^2) / (1 + t^2);
sin_phi = 2 * t / (1 + t^2);
% Substitute parametric forms into coupler components
coupler_parametric = subs(coupler, [cos(phi), sin(phi)], [cos_phi, sin_phi]);
% Display the parametric coupler
disp(‘Parametric form of coupler:’);
disp(coupler_parametric);
syms targetvalue % it might be 3.5 …
normsq = expand(sum(coupler_parametric.^2) – targetvalue^2);
normpoly = simplify(normsq*(t^2+1)^2);
vpa(expand(normpoly),4);
tsolve = solve(normpoly,t,’maxdegree’,4,’returnconditions’,true);
h=vpa(subs(tsolve.t,targetvalue, 106));
%disp(h);
real_solutions = h(imag(h) == 0);
disp(‘Real roots:’);
disp(real_solutions);
% Convert real values of t to angles using angle = 2 * atan(t)
angles_rad = 2 * atan(real_solutions);
angles_deg = rad2deg(angles_rad);
% Display angles in degrees
disp(‘Angles in degrees before adjustment:’);
disp(angles_deg);
phi=double(angles_rad(1));
p=double(angles_deg(1));
c1_position = double(rot_matrix(u3, phi) * (c1′ – a_final’) + a_final’);
p=(c1_position’-a_final)’;
disp(p’);
disp(p(2)/norm(c1_position’-a_final));
final_angle_phi=acosd(p(2)/norm(c1_position’-a_final)); % angle with y axis
disp(final_angle_phi) ;
disp(norm(c1_position’-b1_final));
disp(norm(a_rotated-o2));
%% in this code i want to change theta1 at rate of 90deg/sec and theta2 at rate of 60 deg/sec varying from 0 to 360 deg and want to calculate corresponding value of final_angle_phi with the y axis
%please help someone #angles, #omega MATLAB Answers — New Questions
Training a deep CNN
Which data layout (NHWC, NCHW, or CHWN) is used in trainig a deep CNN? Is there a possibility to choose one of them for the training process?Which data layout (NHWC, NCHW, or CHWN) is used in trainig a deep CNN? Is there a possibility to choose one of them for the training process? Which data layout (NHWC, NCHW, or CHWN) is used in trainig a deep CNN? Is there a possibility to choose one of them for the training process? deep learning, cnn, nhwc, nchw MATLAB Answers — New Questions
Analyzing data sets that are not statistically significant
I have the attached data. Those are the testing results of fibre reinforced cement mortars. First column indicates lengths of fibre used and the second column indicates the volume ratios. Third coloumn I have porosity data. I analysed all the data statistically, but no combination found statistically significant (Based on P-vale, correlation coefficient and R-squared). Sometimes may be due to only three data points for each combination (For an instance at 6 mm length, how volume ratios affect porosity have three data points and etc.)So I would kindly would like to know wehther nay other machine learning or techniques are available to interpret these data interestingly and effectively to the scintific community? Becuase, as this, I have 4 more test paramters (not only porosity) and four fibre types as well.
THnak you in advance.I have the attached data. Those are the testing results of fibre reinforced cement mortars. First column indicates lengths of fibre used and the second column indicates the volume ratios. Third coloumn I have porosity data. I analysed all the data statistically, but no combination found statistically significant (Based on P-vale, correlation coefficient and R-squared). Sometimes may be due to only three data points for each combination (For an instance at 6 mm length, how volume ratios affect porosity have three data points and etc.)So I would kindly would like to know wehther nay other machine learning or techniques are available to interpret these data interestingly and effectively to the scintific community? Becuase, as this, I have 4 more test paramters (not only porosity) and four fibre types as well.
THnak you in advance. I have the attached data. Those are the testing results of fibre reinforced cement mortars. First column indicates lengths of fibre used and the second column indicates the volume ratios. Third coloumn I have porosity data. I analysed all the data statistically, but no combination found statistically significant (Based on P-vale, correlation coefficient and R-squared). Sometimes may be due to only three data points for each combination (For an instance at 6 mm length, how volume ratios affect porosity have three data points and etc.)So I would kindly would like to know wehther nay other machine learning or techniques are available to interpret these data interestingly and effectively to the scintific community? Becuase, as this, I have 4 more test paramters (not only porosity) and four fibre types as well.
THnak you in advance. data, analysis MATLAB Answers — New Questions
HELP PLEASE xpected Servo Input to be one of these types: numeric
PLEASE HELP I GOT THIS ERRORPLEASE HELP I GOT THIS ERROR PLEASE HELP I GOT THIS ERROR simulink, servo, potentiometer MATLAB Answers — New Questions
Struggling with FMU Exporting Simscape components, they work fine in simscape, but when I export to FMU and resimulate to test, the model fails.
I’m currently making a simple physical system (Gas, Mechanical in Simscape, consisting of a reservoir, two Compressors (G) (with an ideal angular velocity source), a Pipe (G) with a controlled heat flow source providing cooling, and a reservoir downstream to sink to. It’s a very simple system and more just being used as a high level model to test out FMU exports. None of the components are changed from default except for the Reservoirs, Heat Flow Sources providing some BCs, and the Compressor has Analytical parameterization and is being set to a specific design point based on a compressor data set that’s being used.
The model works fine in Simscape, I have a controller that admittedly takes a while to reach steady state but aside from that I’ve not seen any issues. When I export this model as an FMU, the model seems to break. I use the inputs that I’ve had before but they seem to break the model and give the following error:
Log from FMU: [category:logStatusError, status:fmi2Error] fmi2ExitInitializationMode(Output): : The co-simulation model block ‘FMU_Testbed/FMU’ is not running.
Log from FMU: [category:logAll, status:fmi2OK] CommunicationPoint=0, communicationStepSize=100.
Log from FMU: [category:logStatusError, status:fmi2Error] fmi2DoStep(Output): : The co-simulation model block ‘FMU_Testbed/FMU’ is not running.
Log from FMU: [category:logStatusError, status:fmi2Error] fmi2FreeInstance: The following error occurred while simulating model ‘PASS_nodata_fmu_draft’ : Initial conditions solve failed to converge.
…Here is the set of components with unconverged equations:
‘PASS_nodata_fmu_draft/Pipe (G)1’
Equation location is:
‘C:/Program Files/MATLAB/R2024a/toolbox/physmod/simscape/library/m/+foundation/+gas/+elements/pipe.ssc’ (line 351)
‘PASS_nodata_fmu_draft/Compressor (G)1’
Equation location is:
‘C:/Program Files/MATLAB/R2024a/toolbox/physmod/fluids/fluids/+fluids/+gas/+turbomachinery/compressor.sscp'(no line number info)
Equation location is:
‘C:/Program Files/MATLAB/R2024a/toolbox/physmod/fluids/fluids/+fluids/+gas/+turbomachinery/compressor.sscp'(no l
Component:Simulink | Category:Model
An error occurred during simulation and the simulation was terminated
Caused by:
Error in supplied FMU: An error occurred in function ‘fmi2DoStep’ for block ‘FMU_Testbed/FMU’ during simulation. For more information, see the FMU troubleshooting documentation.
Component:Simulink | Category:Block error
One theory I have is that because I’ve used Analytical mode as opposed to Tabulated parameterization, the compressor is struggling. This would explain why the FMU does seem to work after I increase the Speed, but the results are inaccurate (going from 0.3 kg/s to 14.3, and going from 101.3kPa to 10*4kPa)
Original Simscape Model:
FMU Block test (Constant inputs from Simscape were turned into inports and I’ve just been testing the FMU to see if they work):
Produces error mentioned earlier
FMU Block test, increased Speed:
Any help here would be appreciatedI’m currently making a simple physical system (Gas, Mechanical in Simscape, consisting of a reservoir, two Compressors (G) (with an ideal angular velocity source), a Pipe (G) with a controlled heat flow source providing cooling, and a reservoir downstream to sink to. It’s a very simple system and more just being used as a high level model to test out FMU exports. None of the components are changed from default except for the Reservoirs, Heat Flow Sources providing some BCs, and the Compressor has Analytical parameterization and is being set to a specific design point based on a compressor data set that’s being used.
The model works fine in Simscape, I have a controller that admittedly takes a while to reach steady state but aside from that I’ve not seen any issues. When I export this model as an FMU, the model seems to break. I use the inputs that I’ve had before but they seem to break the model and give the following error:
Log from FMU: [category:logStatusError, status:fmi2Error] fmi2ExitInitializationMode(Output): : The co-simulation model block ‘FMU_Testbed/FMU’ is not running.
Log from FMU: [category:logAll, status:fmi2OK] CommunicationPoint=0, communicationStepSize=100.
Log from FMU: [category:logStatusError, status:fmi2Error] fmi2DoStep(Output): : The co-simulation model block ‘FMU_Testbed/FMU’ is not running.
Log from FMU: [category:logStatusError, status:fmi2Error] fmi2FreeInstance: The following error occurred while simulating model ‘PASS_nodata_fmu_draft’ : Initial conditions solve failed to converge.
…Here is the set of components with unconverged equations:
‘PASS_nodata_fmu_draft/Pipe (G)1’
Equation location is:
‘C:/Program Files/MATLAB/R2024a/toolbox/physmod/simscape/library/m/+foundation/+gas/+elements/pipe.ssc’ (line 351)
‘PASS_nodata_fmu_draft/Compressor (G)1’
Equation location is:
‘C:/Program Files/MATLAB/R2024a/toolbox/physmod/fluids/fluids/+fluids/+gas/+turbomachinery/compressor.sscp'(no line number info)
Equation location is:
‘C:/Program Files/MATLAB/R2024a/toolbox/physmod/fluids/fluids/+fluids/+gas/+turbomachinery/compressor.sscp'(no l
Component:Simulink | Category:Model
An error occurred during simulation and the simulation was terminated
Caused by:
Error in supplied FMU: An error occurred in function ‘fmi2DoStep’ for block ‘FMU_Testbed/FMU’ during simulation. For more information, see the FMU troubleshooting documentation.
Component:Simulink | Category:Block error
One theory I have is that because I’ve used Analytical mode as opposed to Tabulated parameterization, the compressor is struggling. This would explain why the FMU does seem to work after I increase the Speed, but the results are inaccurate (going from 0.3 kg/s to 14.3, and going from 101.3kPa to 10*4kPa)
Original Simscape Model:
FMU Block test (Constant inputs from Simscape were turned into inports and I’ve just been testing the FMU to see if they work):
Produces error mentioned earlier
FMU Block test, increased Speed:
Any help here would be appreciated I’m currently making a simple physical system (Gas, Mechanical in Simscape, consisting of a reservoir, two Compressors (G) (with an ideal angular velocity source), a Pipe (G) with a controlled heat flow source providing cooling, and a reservoir downstream to sink to. It’s a very simple system and more just being used as a high level model to test out FMU exports. None of the components are changed from default except for the Reservoirs, Heat Flow Sources providing some BCs, and the Compressor has Analytical parameterization and is being set to a specific design point based on a compressor data set that’s being used.
The model works fine in Simscape, I have a controller that admittedly takes a while to reach steady state but aside from that I’ve not seen any issues. When I export this model as an FMU, the model seems to break. I use the inputs that I’ve had before but they seem to break the model and give the following error:
Log from FMU: [category:logStatusError, status:fmi2Error] fmi2ExitInitializationMode(Output): : The co-simulation model block ‘FMU_Testbed/FMU’ is not running.
Log from FMU: [category:logAll, status:fmi2OK] CommunicationPoint=0, communicationStepSize=100.
Log from FMU: [category:logStatusError, status:fmi2Error] fmi2DoStep(Output): : The co-simulation model block ‘FMU_Testbed/FMU’ is not running.
Log from FMU: [category:logStatusError, status:fmi2Error] fmi2FreeInstance: The following error occurred while simulating model ‘PASS_nodata_fmu_draft’ : Initial conditions solve failed to converge.
…Here is the set of components with unconverged equations:
‘PASS_nodata_fmu_draft/Pipe (G)1’
Equation location is:
‘C:/Program Files/MATLAB/R2024a/toolbox/physmod/simscape/library/m/+foundation/+gas/+elements/pipe.ssc’ (line 351)
‘PASS_nodata_fmu_draft/Compressor (G)1’
Equation location is:
‘C:/Program Files/MATLAB/R2024a/toolbox/physmod/fluids/fluids/+fluids/+gas/+turbomachinery/compressor.sscp'(no line number info)
Equation location is:
‘C:/Program Files/MATLAB/R2024a/toolbox/physmod/fluids/fluids/+fluids/+gas/+turbomachinery/compressor.sscp'(no l
Component:Simulink | Category:Model
An error occurred during simulation and the simulation was terminated
Caused by:
Error in supplied FMU: An error occurred in function ‘fmi2DoStep’ for block ‘FMU_Testbed/FMU’ during simulation. For more information, see the FMU troubleshooting documentation.
Component:Simulink | Category:Block error
One theory I have is that because I’ve used Analytical mode as opposed to Tabulated parameterization, the compressor is struggling. This would explain why the FMU does seem to work after I increase the Speed, but the results are inaccurate (going from 0.3 kg/s to 14.3, and going from 101.3kPa to 10*4kPa)
Original Simscape Model:
FMU Block test (Constant inputs from Simscape were turned into inports and I’ve just been testing the FMU to see if they work):
Produces error mentioned earlier
FMU Block test, increased Speed:
Any help here would be appreciated compressor (g), matlab, simscape, fluids, simulink, fmu, export MATLAB Answers — New Questions
how to have an optional bus signal inside a subsystem?
Hello,
I want to create a subsystem that I can reuse in different scenarios (maybe as subsystem reference, not really important).
I would like to pass the signal to this subsystem as a virtual bus.
Inside the subsystem I use the in bus element to get the signals I need from the bus.
Now, since I use this subsystem in different models/configurations there are signals that sometimes are present and sometimes are not present inside the virtual bus, like in the example image below: signal3 is not present inside the bus and so simulink throws the error:
Selected signal ‘signal3’ in the Bus Element Inport block ‘untitledeee/Subsystem1/In Bus Element1’ cannot be found in the input bus signal.
I would like to use a default value when I recognize that the input is missing. In matlab functions you can easily do this with optional arguments (link: arguments – defaultValue).
My question is: there is a way to replicate the optional arguments of matlab functions inside a subsystem/reference subsystem/model reference?
There is some suggested workaround?Hello,
I want to create a subsystem that I can reuse in different scenarios (maybe as subsystem reference, not really important).
I would like to pass the signal to this subsystem as a virtual bus.
Inside the subsystem I use the in bus element to get the signals I need from the bus.
Now, since I use this subsystem in different models/configurations there are signals that sometimes are present and sometimes are not present inside the virtual bus, like in the example image below: signal3 is not present inside the bus and so simulink throws the error:
Selected signal ‘signal3’ in the Bus Element Inport block ‘untitledeee/Subsystem1/In Bus Element1’ cannot be found in the input bus signal.
I would like to use a default value when I recognize that the input is missing. In matlab functions you can easily do this with optional arguments (link: arguments – defaultValue).
My question is: there is a way to replicate the optional arguments of matlab functions inside a subsystem/reference subsystem/model reference?
There is some suggested workaround? Hello,
I want to create a subsystem that I can reuse in different scenarios (maybe as subsystem reference, not really important).
I would like to pass the signal to this subsystem as a virtual bus.
Inside the subsystem I use the in bus element to get the signals I need from the bus.
Now, since I use this subsystem in different models/configurations there are signals that sometimes are present and sometimes are not present inside the virtual bus, like in the example image below: signal3 is not present inside the bus and so simulink throws the error:
Selected signal ‘signal3’ in the Bus Element Inport block ‘untitledeee/Subsystem1/In Bus Element1’ cannot be found in the input bus signal.
I would like to use a default value when I recognize that the input is missing. In matlab functions you can easily do this with optional arguments (link: arguments – defaultValue).
My question is: there is a way to replicate the optional arguments of matlab functions inside a subsystem/reference subsystem/model reference?
There is some suggested workaround? model reference, input, bus, model, simulink MATLAB Answers — New Questions
java.awt.IllegalComponentStateException: The frame is decorated
Hi,
I got the following error from an old code that I am trying to fix to work in modern version of matlab: (If there is an easy way to fix the bug, would be really helpful!)
Java exception occurred:
java.awt.IllegalComponentStateException: The frame is decorated
at java.awt.Frame.setOpacity(Frame.java:960)
at java.awt.Window$1.setOpacity(Window.java:4037)
at com.sun.awt.AWTUtilities.setWindowOpacity(AWTUtilities.java:174)
The original code is the following:
for stepIdx = 1 : 10
if stepIdx == 1
com.sun.awt.AWTUtilities.setWindowOpacity(jWindow1,0.01)
pause(0.25)
end
newAlpha = -.01 + 0.1*stepIdx;
com.sun.awt.AWTUtilities.setWindowOpacity(jWindow1,newAlpha)
jWindow1.repaint;
endHi,
I got the following error from an old code that I am trying to fix to work in modern version of matlab: (If there is an easy way to fix the bug, would be really helpful!)
Java exception occurred:
java.awt.IllegalComponentStateException: The frame is decorated
at java.awt.Frame.setOpacity(Frame.java:960)
at java.awt.Window$1.setOpacity(Window.java:4037)
at com.sun.awt.AWTUtilities.setWindowOpacity(AWTUtilities.java:174)
The original code is the following:
for stepIdx = 1 : 10
if stepIdx == 1
com.sun.awt.AWTUtilities.setWindowOpacity(jWindow1,0.01)
pause(0.25)
end
newAlpha = -.01 + 0.1*stepIdx;
com.sun.awt.AWTUtilities.setWindowOpacity(jWindow1,newAlpha)
jWindow1.repaint;
end Hi,
I got the following error from an old code that I am trying to fix to work in modern version of matlab: (If there is an easy way to fix the bug, would be really helpful!)
Java exception occurred:
java.awt.IllegalComponentStateException: The frame is decorated
at java.awt.Frame.setOpacity(Frame.java:960)
at java.awt.Window$1.setOpacity(Window.java:4037)
at com.sun.awt.AWTUtilities.setWindowOpacity(AWTUtilities.java:174)
The original code is the following:
for stepIdx = 1 : 10
if stepIdx == 1
com.sun.awt.AWTUtilities.setWindowOpacity(jWindow1,0.01)
pause(0.25)
end
newAlpha = -.01 + 0.1*stepIdx;
com.sun.awt.AWTUtilities.setWindowOpacity(jWindow1,newAlpha)
jWindow1.repaint;
end java frame MATLAB Answers — New Questions
Parfor Execution time variation
Hi,
I am using parfor for reading 600 .raw files.
c=zeros(1536,1536,600,’uint16′);
parpool(‘threads’,4);
parfor i=1:600
fileName=[folder,’/’,fileList(i).name];
a=fopen(fileName,’r’);
Z=fread(a,[1536 1536],’uint16′);
fclose(a);
c(:,:,i)=Z;
end
However, I am observing significant variability in the execution time, which ranges from 14 seconds to 110 seconds across different runs.
Why is this discrepancy occurring? Is there a way to achieve more consistent execution times?Hi,
I am using parfor for reading 600 .raw files.
c=zeros(1536,1536,600,’uint16′);
parpool(‘threads’,4);
parfor i=1:600
fileName=[folder,’/’,fileList(i).name];
a=fopen(fileName,’r’);
Z=fread(a,[1536 1536],’uint16′);
fclose(a);
c(:,:,i)=Z;
end
However, I am observing significant variability in the execution time, which ranges from 14 seconds to 110 seconds across different runs.
Why is this discrepancy occurring? Is there a way to achieve more consistent execution times? Hi,
I am using parfor for reading 600 .raw files.
c=zeros(1536,1536,600,’uint16′);
parpool(‘threads’,4);
parfor i=1:600
fileName=[folder,’/’,fileList(i).name];
a=fopen(fileName,’r’);
Z=fread(a,[1536 1536],’uint16′);
fclose(a);
c(:,:,i)=Z;
end
However, I am observing significant variability in the execution time, which ranges from 14 seconds to 110 seconds across different runs.
Why is this discrepancy occurring? Is there a way to achieve more consistent execution times? parfor, parallel computing, parallel computing toolbox MATLAB Answers — New Questions
How can I get the predicted YValidation data using LSTM model?
Hi, I did a LSTM model, just like the link mentioned(https://ww2.mathworks.cn/help/deeplearning/ref/trainnetwork.html), I specified the ValidationData in the opts.
options = trainingOptions("sgdm", …
MaxEpochs=8, …
ValidationData={XValidation,YValidation}, …
ValidationFrequency=30, …
Verbose=false, …
Plots="training-progress");
Because I want draw a picture including the YValidation data(which I specified) and predicted-YValidation data(which derived from the training net), the question is "How can I get the predicted YValidation data"?
Thank you!Hi, I did a LSTM model, just like the link mentioned(https://ww2.mathworks.cn/help/deeplearning/ref/trainnetwork.html), I specified the ValidationData in the opts.
options = trainingOptions("sgdm", …
MaxEpochs=8, …
ValidationData={XValidation,YValidation}, …
ValidationFrequency=30, …
Verbose=false, …
Plots="training-progress");
Because I want draw a picture including the YValidation data(which I specified) and predicted-YValidation data(which derived from the training net), the question is "How can I get the predicted YValidation data"?
Thank you! Hi, I did a LSTM model, just like the link mentioned(https://ww2.mathworks.cn/help/deeplearning/ref/trainnetwork.html), I specified the ValidationData in the opts.
options = trainingOptions("sgdm", …
MaxEpochs=8, …
ValidationData={XValidation,YValidation}, …
ValidationFrequency=30, …
Verbose=false, …
Plots="training-progress");
Because I want draw a picture including the YValidation data(which I specified) and predicted-YValidation data(which derived from the training net), the question is "How can I get the predicted YValidation data"?
Thank you! lstm, validation data MATLAB Answers — New Questions
Using simulink runtime data in callback functions
Hello, I am stressedup with App Designer. I have stateflow model in Simulink to be controlled from an app built in app designer. I am able to creat a Listener and a run time object in an updateGui helper function.
properties (Access = public)
status3; % Description
end
methods (Access = public)
function updateGUI(app, varargin)
% Create an object that gets the run-time value of the specified block
rto_2 = get_param(‘ChargingProcess/Display3′,’RuntimeObject’);
rto1 = get_param(‘ChargingProcess/CarBatteryOut1′,’RuntimeObject’);
% Update the GUI accordingly.
app.status3 = rto_2.InputPort(1).Data.char;
% app.EditField.Value = rto_2.InputPort(1).Data.char;
% Assign input from Car Battery Level(CarBatteryOut1) to Car Battery level 1 editfield
app.CarBatteryLevel1EditField.Value = rto1.InputPort(1).Data;
end
end
there are other objects which are not very necessary now
This works well and displays the information on the app as I want. Now, i need some of this information (status3) in a push button callback to control a a switch. First issue is that I cannot access the varriable status3 directly in a callback function. I treid to declear it as a property and call it in the button callback funtion. It is called but does not update as the simulation progresses.
The main idea is for the switch controlled by the button callback function to stay on ‘1’ when the button is pressed to the point when status3 matches a particular string ‘WaitAtStation’ and a certain edith field vallue == 100. In this case, I used a while loop. I treid to output the edith field value (gotten from simulink too ) with the same callback funtion but it also does not update as the value in the edith field changes
striingValue = num2str(app.status3)
function Charge1ButtonPushed(app, event)
set_param(‘ChargingProcess/ChargeMyCar1′,’sw’,’1′);
while (app.CarBatteryLevel1EditField.Value == 100 && strcmp(stringValue, ~’WaitAtStation’))
set_param(‘ChargingProcess/ChargeMyCar1′,’sw’,’0′);
end
end
This either doesnt work or freezes my system when the button is pushed. What i actually need help is;
1) How to get status3 and the app.CarBatteryLevel1EditField.Value in my callback function that will update as the actuall vallues change in simulink
2) A better way represent the logic because the while loop appears not to be doing the jobHello, I am stressedup with App Designer. I have stateflow model in Simulink to be controlled from an app built in app designer. I am able to creat a Listener and a run time object in an updateGui helper function.
properties (Access = public)
status3; % Description
end
methods (Access = public)
function updateGUI(app, varargin)
% Create an object that gets the run-time value of the specified block
rto_2 = get_param(‘ChargingProcess/Display3′,’RuntimeObject’);
rto1 = get_param(‘ChargingProcess/CarBatteryOut1′,’RuntimeObject’);
% Update the GUI accordingly.
app.status3 = rto_2.InputPort(1).Data.char;
% app.EditField.Value = rto_2.InputPort(1).Data.char;
% Assign input from Car Battery Level(CarBatteryOut1) to Car Battery level 1 editfield
app.CarBatteryLevel1EditField.Value = rto1.InputPort(1).Data;
end
end
there are other objects which are not very necessary now
This works well and displays the information on the app as I want. Now, i need some of this information (status3) in a push button callback to control a a switch. First issue is that I cannot access the varriable status3 directly in a callback function. I treid to declear it as a property and call it in the button callback funtion. It is called but does not update as the simulation progresses.
The main idea is for the switch controlled by the button callback function to stay on ‘1’ when the button is pressed to the point when status3 matches a particular string ‘WaitAtStation’ and a certain edith field vallue == 100. In this case, I used a while loop. I treid to output the edith field value (gotten from simulink too ) with the same callback funtion but it also does not update as the value in the edith field changes
striingValue = num2str(app.status3)
function Charge1ButtonPushed(app, event)
set_param(‘ChargingProcess/ChargeMyCar1′,’sw’,’1′);
while (app.CarBatteryLevel1EditField.Value == 100 && strcmp(stringValue, ~’WaitAtStation’))
set_param(‘ChargingProcess/ChargeMyCar1′,’sw’,’0′);
end
end
This either doesnt work or freezes my system when the button is pushed. What i actually need help is;
1) How to get status3 and the app.CarBatteryLevel1EditField.Value in my callback function that will update as the actuall vallues change in simulink
2) A better way represent the logic because the while loop appears not to be doing the job Hello, I am stressedup with App Designer. I have stateflow model in Simulink to be controlled from an app built in app designer. I am able to creat a Listener and a run time object in an updateGui helper function.
properties (Access = public)
status3; % Description
end
methods (Access = public)
function updateGUI(app, varargin)
% Create an object that gets the run-time value of the specified block
rto_2 = get_param(‘ChargingProcess/Display3′,’RuntimeObject’);
rto1 = get_param(‘ChargingProcess/CarBatteryOut1′,’RuntimeObject’);
% Update the GUI accordingly.
app.status3 = rto_2.InputPort(1).Data.char;
% app.EditField.Value = rto_2.InputPort(1).Data.char;
% Assign input from Car Battery Level(CarBatteryOut1) to Car Battery level 1 editfield
app.CarBatteryLevel1EditField.Value = rto1.InputPort(1).Data;
end
end
there are other objects which are not very necessary now
This works well and displays the information on the app as I want. Now, i need some of this information (status3) in a push button callback to control a a switch. First issue is that I cannot access the varriable status3 directly in a callback function. I treid to declear it as a property and call it in the button callback funtion. It is called but does not update as the simulation progresses.
The main idea is for the switch controlled by the button callback function to stay on ‘1’ when the button is pressed to the point when status3 matches a particular string ‘WaitAtStation’ and a certain edith field vallue == 100. In this case, I used a while loop. I treid to output the edith field value (gotten from simulink too ) with the same callback funtion but it also does not update as the value in the edith field changes
striingValue = num2str(app.status3)
function Charge1ButtonPushed(app, event)
set_param(‘ChargingProcess/ChargeMyCar1′,’sw’,’1′);
while (app.CarBatteryLevel1EditField.Value == 100 && strcmp(stringValue, ~’WaitAtStation’))
set_param(‘ChargingProcess/ChargeMyCar1′,’sw’,’0′);
end
end
This either doesnt work or freezes my system when the button is pushed. What i actually need help is;
1) How to get status3 and the app.CarBatteryLevel1EditField.Value in my callback function that will update as the actuall vallues change in simulink
2) A better way represent the logic because the while loop appears not to be doing the job share information in app designer MATLAB Answers — New Questions
Error ” Too many input arguments” occurs when using nlhw in EXAMPLE
Following the examples here to lear abount estimate nonlinear model.
After
openExample(‘ident/EstimateAHammersteinWienerModelExample’)
and press run button, I got this error output
Error using nlhw
Too many input arguments.
I debug a bit and found the error occurs at this line
[~, uC(~uNoNorm), uS(~uNoNorm)] = normalize(in(:,~uNoNorm),1,PV{:});
But I really did not figure out why. Thanks in advance for your kind help.Following the examples here to lear abount estimate nonlinear model.
After
openExample(‘ident/EstimateAHammersteinWienerModelExample’)
and press run button, I got this error output
Error using nlhw
Too many input arguments.
I debug a bit and found the error occurs at this line
[~, uC(~uNoNorm), uS(~uNoNorm)] = normalize(in(:,~uNoNorm),1,PV{:});
But I really did not figure out why. Thanks in advance for your kind help. Following the examples here to lear abount estimate nonlinear model.
After
openExample(‘ident/EstimateAHammersteinWienerModelExample’)
and press run button, I got this error output
Error using nlhw
Too many input arguments.
I debug a bit and found the error occurs at this line
[~, uC(~uNoNorm), uS(~uNoNorm)] = normalize(in(:,~uNoNorm),1,PV{:});
But I really did not figure out why. Thanks in advance for your kind help. system identification, nlhw, hammerstein-wiener model MATLAB Answers — New Questions
Impact of Electric vehicle charging on the distribution grid
Hey everyone,
I am doing my research on the impact of charging Electric Vehicle on the distribution grid and looking into parameters such as voltage profile, losses and transformer overloading. Are there any power distribution systems already created in Matlab or simulink that i can use for this purpose?Hey everyone,
I am doing my research on the impact of charging Electric Vehicle on the distribution grid and looking into parameters such as voltage profile, losses and transformer overloading. Are there any power distribution systems already created in Matlab or simulink that i can use for this purpose? Hey everyone,
I am doing my research on the impact of charging Electric Vehicle on the distribution grid and looking into parameters such as voltage profile, losses and transformer overloading. Are there any power distribution systems already created in Matlab or simulink that i can use for this purpose? ieee, power distribution systems MATLAB Answers — New Questions
Reattaching Visual Studio debugger fails to detect mex file modules
I am attempting to debug a Matlab "mex" file using Visual Studio.
I can attach Visual Studio to Matlab and set a breakpoint in my mex file source code just fine in the first go-around. When calling the mex file, visual studio stops at the breakpoint, and I note that the mex file is listed in the loaded modules:
However, if I de-attach visual studio, then re-attach, seems that visual studio no longer detects the loaded modules. See screenshot below, there are far fewer modules listed:
This is quite frustrating, as the only way I seem to be able to work around is to quit Matlab and re-start each time in need to re-attach the debugger (i.e. after tweaking code and rebuilding the mex file).
I used to do this all the time in the past (i.e. with VS 2010-2012 / Matlab R2012B-R2017B), but I’m stumped on this now using VS 2015 w/ Matlab R2019B.I am attempting to debug a Matlab "mex" file using Visual Studio.
I can attach Visual Studio to Matlab and set a breakpoint in my mex file source code just fine in the first go-around. When calling the mex file, visual studio stops at the breakpoint, and I note that the mex file is listed in the loaded modules:
However, if I de-attach visual studio, then re-attach, seems that visual studio no longer detects the loaded modules. See screenshot below, there are far fewer modules listed:
This is quite frustrating, as the only way I seem to be able to work around is to quit Matlab and re-start each time in need to re-attach the debugger (i.e. after tweaking code and rebuilding the mex file).
I used to do this all the time in the past (i.e. with VS 2010-2012 / Matlab R2012B-R2017B), but I’m stumped on this now using VS 2015 w/ Matlab R2019B. I am attempting to debug a Matlab "mex" file using Visual Studio.
I can attach Visual Studio to Matlab and set a breakpoint in my mex file source code just fine in the first go-around. When calling the mex file, visual studio stops at the breakpoint, and I note that the mex file is listed in the loaded modules:
However, if I de-attach visual studio, then re-attach, seems that visual studio no longer detects the loaded modules. See screenshot below, there are far fewer modules listed:
This is quite frustrating, as the only way I seem to be able to work around is to quit Matlab and re-start each time in need to re-attach the debugger (i.e. after tweaking code and rebuilding the mex file).
I used to do this all the time in the past (i.e. with VS 2010-2012 / Matlab R2012B-R2017B), but I’m stumped on this now using VS 2015 w/ Matlab R2019B. mex compiler, debug, mex, visual studio MATLAB Answers — New Questions
Matlab function to take matrix as input and return elements in its four corners as output
Hello, good day all, please I’m having difficulties writing a function to take a matrix input, and return the elements in its cour corners as an output.
Here is my code:
function [top_left,top_right,bottom_left,bottom_right] = corners(i,r,c)
A = matrix(i,r,c)
top_left = A(1,1);
top_right = A(1,c);
bottom_left = A(r,1);
bottom_right = A(r,c);
function B = matrix(i,r,c)
ind = i;
row = r;
col = c;
B = randi(ind,row,col);
I keep getting Not enough input arguments.
Error in corners (line 2)
A = matrix(i,r,c)
I’ll appreciate your response. Thanks.Hello, good day all, please I’m having difficulties writing a function to take a matrix input, and return the elements in its cour corners as an output.
Here is my code:
function [top_left,top_right,bottom_left,bottom_right] = corners(i,r,c)
A = matrix(i,r,c)
top_left = A(1,1);
top_right = A(1,c);
bottom_left = A(r,1);
bottom_right = A(r,c);
function B = matrix(i,r,c)
ind = i;
row = r;
col = c;
B = randi(ind,row,col);
I keep getting Not enough input arguments.
Error in corners (line 2)
A = matrix(i,r,c)
I’ll appreciate your response. Thanks. Hello, good day all, please I’m having difficulties writing a function to take a matrix input, and return the elements in its cour corners as an output.
Here is my code:
function [top_left,top_right,bottom_left,bottom_right] = corners(i,r,c)
A = matrix(i,r,c)
top_left = A(1,1);
top_right = A(1,c);
bottom_left = A(r,1);
bottom_right = A(r,c);
function B = matrix(i,r,c)
ind = i;
row = r;
col = c;
B = randi(ind,row,col);
I keep getting Not enough input arguments.
Error in corners (line 2)
A = matrix(i,r,c)
I’ll appreciate your response. Thanks. matrix and functions MATLAB Answers — New Questions
Matrix of fading colors
I’m trying to make a 256×256 matrix of colors fading into each other. The top left corner is red, the top right is purple, the bottom right is blue, and the bottom left is green. The blue and the red fade into each other, which is easy to figure out. The problem is the green fades out radially, in both directions, and I can’t get my image to do that. My code so far is:
mat3d(:,:,1) = zeros(256,256);
mat3d(:,:,2) = zeros(256,256);
mat3d(:,:,3) = zeros(256,256);
increase = linspace(0,1,256);
decrease = linspace(1,0,256);
for i = 1:256
mat3d(i,:,1) = decrease(i);
mat3d(:,i,3) = increase(i);
for j = 1:256
dist = sqrt((256-i)^2+(256-j)^2);
end
end
I can’t figure out how to write the last for loop.I’m trying to make a 256×256 matrix of colors fading into each other. The top left corner is red, the top right is purple, the bottom right is blue, and the bottom left is green. The blue and the red fade into each other, which is easy to figure out. The problem is the green fades out radially, in both directions, and I can’t get my image to do that. My code so far is:
mat3d(:,:,1) = zeros(256,256);
mat3d(:,:,2) = zeros(256,256);
mat3d(:,:,3) = zeros(256,256);
increase = linspace(0,1,256);
decrease = linspace(1,0,256);
for i = 1:256
mat3d(i,:,1) = decrease(i);
mat3d(:,i,3) = increase(i);
for j = 1:256
dist = sqrt((256-i)^2+(256-j)^2);
end
end
I can’t figure out how to write the last for loop. I’m trying to make a 256×256 matrix of colors fading into each other. The top left corner is red, the top right is purple, the bottom right is blue, and the bottom left is green. The blue and the red fade into each other, which is easy to figure out. The problem is the green fades out radially, in both directions, and I can’t get my image to do that. My code so far is:
mat3d(:,:,1) = zeros(256,256);
mat3d(:,:,2) = zeros(256,256);
mat3d(:,:,3) = zeros(256,256);
increase = linspace(0,1,256);
decrease = linspace(1,0,256);
for i = 1:256
mat3d(i,:,1) = decrease(i);
mat3d(:,i,3) = increase(i);
for j = 1:256
dist = sqrt((256-i)^2+(256-j)^2);
end
end
I can’t figure out how to write the last for loop. images, colors, fading colors, script MATLAB Answers — New Questions
System Generator for DSP 14.7 is only compatible with MATLAB 2013b?
https://www.xilinx.com/support/answers/17966.html
According to Xilinx AR# 17966
DSP Tools, System Generator for DSP, AccelDSP – Which versions of System Generator for DSP and AccelDSP synthesis tool are compatible with which versions of ISE design tools and MATLAB
It says System Generator for DSP 14.7 is only compatible with MATLAB 2013b?
Is this true?
System Generator for DSP 14.7
Operating System Support:
Windows 7 Professional
Windows XP Professional
Windows Server 2008 (64-bit)
Red Hat Enterprise 6 Workstation
Red Hat Enterprise 5 Workstation
SUSE Linux Enterprise 11
Support for 32-bit and 64-bit on all OS
Required:
ISE Design Suite 14.7 System Edition
MATLAB 2012a, 2012b, 2013a and 2013b from the MathWorks (requires Simulink Fixed-Point Toolbox for bus-widths greater than 53 bits)
Optional:
Synopsys Synplify Pro H-2013.03
Mentor Graphics ModelSim 10.1bhttps://www.xilinx.com/support/answers/17966.html
According to Xilinx AR# 17966
DSP Tools, System Generator for DSP, AccelDSP – Which versions of System Generator for DSP and AccelDSP synthesis tool are compatible with which versions of ISE design tools and MATLAB
It says System Generator for DSP 14.7 is only compatible with MATLAB 2013b?
Is this true?
System Generator for DSP 14.7
Operating System Support:
Windows 7 Professional
Windows XP Professional
Windows Server 2008 (64-bit)
Red Hat Enterprise 6 Workstation
Red Hat Enterprise 5 Workstation
SUSE Linux Enterprise 11
Support for 32-bit and 64-bit on all OS
Required:
ISE Design Suite 14.7 System Edition
MATLAB 2012a, 2012b, 2013a and 2013b from the MathWorks (requires Simulink Fixed-Point Toolbox for bus-widths greater than 53 bits)
Optional:
Synopsys Synplify Pro H-2013.03
Mentor Graphics ModelSim 10.1b https://www.xilinx.com/support/answers/17966.html
According to Xilinx AR# 17966
DSP Tools, System Generator for DSP, AccelDSP – Which versions of System Generator for DSP and AccelDSP synthesis tool are compatible with which versions of ISE design tools and MATLAB
It says System Generator for DSP 14.7 is only compatible with MATLAB 2013b?
Is this true?
System Generator for DSP 14.7
Operating System Support:
Windows 7 Professional
Windows XP Professional
Windows Server 2008 (64-bit)
Red Hat Enterprise 6 Workstation
Red Hat Enterprise 5 Workstation
SUSE Linux Enterprise 11
Support for 32-bit and 64-bit on all OS
Required:
ISE Design Suite 14.7 System Edition
MATLAB 2012a, 2012b, 2013a and 2013b from the MathWorks (requires Simulink Fixed-Point Toolbox for bus-widths greater than 53 bits)
Optional:
Synopsys Synplify Pro H-2013.03
Mentor Graphics ModelSim 10.1b simulink MATLAB Answers — New Questions
App Designer UIAxes Interactions not working when UIFigure WindowButtonMotion callback set
I want to use the WindowButtonMotion callback to produce a ‘hover’ effect on various images that I’m using as buttons on an App I’m designing, but it looks like just turning on the UIFigure’s WindowButtonMotion callback completely disables interactivity (pan, rotate, etc.) with the UIAxes. I have a surface plot showing a 3D render of the data the user is visualizing, but it becomes completely non-interactive when I use buttonmotion callbacks to track mouse movements for the mouse hover.
I’ve tried various ways to get around this, including setting the UIAxes.View property as a function of mouse positions when the mouse is within the UIAxes, but this seems really clunky, and I can’t seem to work out how to ‘click & drag’ to interact with the surface plot correctly.
Any solutions to re-enable plot interactions? I’m working on Matlab 2019a.I want to use the WindowButtonMotion callback to produce a ‘hover’ effect on various images that I’m using as buttons on an App I’m designing, but it looks like just turning on the UIFigure’s WindowButtonMotion callback completely disables interactivity (pan, rotate, etc.) with the UIAxes. I have a surface plot showing a 3D render of the data the user is visualizing, but it becomes completely non-interactive when I use buttonmotion callbacks to track mouse movements for the mouse hover.
I’ve tried various ways to get around this, including setting the UIAxes.View property as a function of mouse positions when the mouse is within the UIAxes, but this seems really clunky, and I can’t seem to work out how to ‘click & drag’ to interact with the surface plot correctly.
Any solutions to re-enable plot interactions? I’m working on Matlab 2019a. I want to use the WindowButtonMotion callback to produce a ‘hover’ effect on various images that I’m using as buttons on an App I’m designing, but it looks like just turning on the UIFigure’s WindowButtonMotion callback completely disables interactivity (pan, rotate, etc.) with the UIAxes. I have a surface plot showing a 3D render of the data the user is visualizing, but it becomes completely non-interactive when I use buttonmotion callbacks to track mouse movements for the mouse hover.
I’ve tried various ways to get around this, including setting the UIAxes.View property as a function of mouse positions when the mouse is within the UIAxes, but this seems really clunky, and I can’t seem to work out how to ‘click & drag’ to interact with the surface plot correctly.
Any solutions to re-enable plot interactions? I’m working on Matlab 2019a. appdesigner, uiaxes, interactions, pan, zoom, windowbuttonmotion, 3drotate, callback events MATLAB Answers — New Questions