Category: Matlab
Category Archives: Matlab
Output figure as white background in dark mode [2023b beta]
Dear all,
I appreciate for dark mode in 2023b version. However, for the output figure, my output figure works also based on dark mode which means black background and white text color. I take effort to change into "white mode" figure (white background, black text color). I used below code but it just work for one-by-one figure.
set(gca, ‘Color’,’w’, ‘XColor’,’k’, ‘YColor’,’k’)
set(gcf, ‘Color’,’w’)
set(gca,XScale=’log’);
colorPropObjs = findobj(gcf, "-property", "Color");
colorPropObjs(2).Color = [1.0000 1.0000 1.0000];
set(0,’defaultfigurecolor’,[1 1 1]);
I would like to ask there are any ways to work on dark mode but the output figure as normal as white mode. or we can set up output figure at one time.
Thank you for your time,
Best regards,Dear all,
I appreciate for dark mode in 2023b version. However, for the output figure, my output figure works also based on dark mode which means black background and white text color. I take effort to change into "white mode" figure (white background, black text color). I used below code but it just work for one-by-one figure.
set(gca, ‘Color’,’w’, ‘XColor’,’k’, ‘YColor’,’k’)
set(gcf, ‘Color’,’w’)
set(gca,XScale=’log’);
colorPropObjs = findobj(gcf, "-property", "Color");
colorPropObjs(2).Color = [1.0000 1.0000 1.0000];
set(0,’defaultfigurecolor’,[1 1 1]);
I would like to ask there are any ways to work on dark mode but the output figure as normal as white mode. or we can set up output figure at one time.
Thank you for your time,
Best regards, Dear all,
I appreciate for dark mode in 2023b version. However, for the output figure, my output figure works also based on dark mode which means black background and white text color. I take effort to change into "white mode" figure (white background, black text color). I used below code but it just work for one-by-one figure.
set(gca, ‘Color’,’w’, ‘XColor’,’k’, ‘YColor’,’k’)
set(gcf, ‘Color’,’w’)
set(gca,XScale=’log’);
colorPropObjs = findobj(gcf, "-property", "Color");
colorPropObjs(2).Color = [1.0000 1.0000 1.0000];
set(0,’defaultfigurecolor’,[1 1 1]);
I would like to ask there are any ways to work on dark mode but the output figure as normal as white mode. or we can set up output figure at one time.
Thank you for your time,
Best regards, dark mode, output figure, themes, r2023b MATLAB Answers — New Questions
Error Using * and ^
I am trying to ;
varV = sqrt(s^2*var(‘Texaco’)^2 + (1-s)^2*var(‘Exxon’)^2 + 2*s*(1-s)*cov(Texaco,Exxon))
but it gives me
Error using ^
Inputs must be a scalar and a square matrix.
To compute elementwise POWER, use POWER (.^) instead.
After I arrange like this :
varV = sqrt((s.^2)*var(Texaco).^2 + ((1-s).^2)*var(Exxon).^2 + 2*s*(1-s)*cov(Texaco,Exxon))
It gives me :
Error using *
Inner matrix dimensions must agree.
How can I arrange this correctly ?
Note:Texaco and Exxon are my imported datas.I am trying to ;
varV = sqrt(s^2*var(‘Texaco’)^2 + (1-s)^2*var(‘Exxon’)^2 + 2*s*(1-s)*cov(Texaco,Exxon))
but it gives me
Error using ^
Inputs must be a scalar and a square matrix.
To compute elementwise POWER, use POWER (.^) instead.
After I arrange like this :
varV = sqrt((s.^2)*var(Texaco).^2 + ((1-s).^2)*var(Exxon).^2 + 2*s*(1-s)*cov(Texaco,Exxon))
It gives me :
Error using *
Inner matrix dimensions must agree.
How can I arrange this correctly ?
Note:Texaco and Exxon are my imported datas. I am trying to ;
varV = sqrt(s^2*var(‘Texaco’)^2 + (1-s)^2*var(‘Exxon’)^2 + 2*s*(1-s)*cov(Texaco,Exxon))
but it gives me
Error using ^
Inputs must be a scalar and a square matrix.
To compute elementwise POWER, use POWER (.^) instead.
After I arrange like this :
varV = sqrt((s.^2)*var(Texaco).^2 + ((1-s).^2)*var(Exxon).^2 + 2*s*(1-s)*cov(Texaco,Exxon))
It gives me :
Error using *
Inner matrix dimensions must agree.
How can I arrange this correctly ?
Note:Texaco and Exxon are my imported datas. error * ^ MATLAB Answers — New Questions
How to run all the image with format jpg in folder? and save into folder?
Hello. Anyone know how to run a folder with thousand images instead of run one by one the image? and save into folder?
I=imread(’11_285.jpg’);
imshow(I)
magnificationFactor = 1.2;
J=imresize(I,magnificationFactor, ‘bilinear’);
imshowpair(I,J,method="montage")
imwrite(J,’11_285_rescale.jpg’);Hello. Anyone know how to run a folder with thousand images instead of run one by one the image? and save into folder?
I=imread(’11_285.jpg’);
imshow(I)
magnificationFactor = 1.2;
J=imresize(I,magnificationFactor, ‘bilinear’);
imshowpair(I,J,method="montage")
imwrite(J,’11_285_rescale.jpg’); Hello. Anyone know how to run a folder with thousand images instead of run one by one the image? and save into folder?
I=imread(’11_285.jpg’);
imshow(I)
magnificationFactor = 1.2;
J=imresize(I,magnificationFactor, ‘bilinear’);
imshowpair(I,J,method="montage")
imwrite(J,’11_285_rescale.jpg’); images, folder, save MATLAB Answers — New Questions
CLI is not running when i set absolute path
When using CLI in polyspace path polyspace-bug-finder runs normally.
but in absolute path and run it, it will not run.
I think, There are no different, so how i can use absolute path to make auto CLI code?When using CLI in polyspace path polyspace-bug-finder runs normally.
but in absolute path and run it, it will not run.
I think, There are no different, so how i can use absolute path to make auto CLI code? When using CLI in polyspace path polyspace-bug-finder runs normally.
but in absolute path and run it, it will not run.
I think, There are no different, so how i can use absolute path to make auto CLI code? path, absolute path MATLAB Answers — New Questions
The training accuracy and the validation accuracy stay in the range of 50%
Can Anyone help me to understand why the CNN model behave as shown in the SampleCan Anyone help me to understand why the CNN model behave as shown in the Sample Can Anyone help me to understand why the CNN model behave as shown in the Sample cnn, computer vision, deep learning, machine learning MATLAB Answers — New Questions
MCSA spectral analysis using FFT
Hi,
I’m new to matlab. I have to do FFT and plots of spectral analysis of an induction motor with short circuit. Here in zip I have csv file (I also have same matlab file if necessary, don’t know what is better) of one phase (without fault). I’ve been trying for several throws to create something, but no luck. The sampling frequency was 5000000 Hz, the recording length was 0,2 s and the number of samples was 1000000. Can I ask for help. Thank you very much.Hi,
I’m new to matlab. I have to do FFT and plots of spectral analysis of an induction motor with short circuit. Here in zip I have csv file (I also have same matlab file if necessary, don’t know what is better) of one phase (without fault). I’ve been trying for several throws to create something, but no luck. The sampling frequency was 5000000 Hz, the recording length was 0,2 s and the number of samples was 1000000. Can I ask for help. Thank you very much. Hi,
I’m new to matlab. I have to do FFT and plots of spectral analysis of an induction motor with short circuit. Here in zip I have csv file (I also have same matlab file if necessary, don’t know what is better) of one phase (without fault). I’ve been trying for several throws to create something, but no luck. The sampling frequency was 5000000 Hz, the recording length was 0,2 s and the number of samples was 1000000. Can I ask for help. Thank you very much. fft, spectral analysis MATLAB Answers — New Questions
How to give random inputs for my simulink design?
I have created a model using importhdl ie. from my verilog code. Now I want to test it with many random inputs just like we do simulation testing on iVerilog or Quartus Prime or any other HDL tool. How can I do that as if I use constant then it works for only one input at a time?I have created a model using importhdl ie. from my verilog code. Now I want to test it with many random inputs just like we do simulation testing on iVerilog or Quartus Prime or any other HDL tool. How can I do that as if I use constant then it works for only one input at a time? I have created a model using importhdl ie. from my verilog code. Now I want to test it with many random inputs just like we do simulation testing on iVerilog or Quartus Prime or any other HDL tool. How can I do that as if I use constant then it works for only one input at a time? simulink, digital image processing, importhdl, random number generator MATLAB Answers — New Questions
simulation of a rov in simscape
I exported a model of an ROV from Solidwork to Simulink I got my model with my 6 degrees of freedom however when pressing run to simulate my ROV the model does not move towards the x, y, z axes, I don’t know what, how to do it to be able to simulate my ROV and see its displacement, please orient meI exported a model of an ROV from Solidwork to Simulink I got my model with my 6 degrees of freedom however when pressing run to simulate my ROV the model does not move towards the x, y, z axes, I don’t know what, how to do it to be able to simulate my ROV and see its displacement, please orient me I exported a model of an ROV from Solidwork to Simulink I got my model with my 6 degrees of freedom however when pressing run to simulate my ROV the model does not move towards the x, y, z axes, I don’t know what, how to do it to be able to simulate my ROV and see its displacement, please orient me simscape MATLAB Answers — New Questions
Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
I’m run this script. Could someone help me
rvar_selec=find(sum(Rsel_matrix)>=(ncut)); if (length(rvar_selec)==0) rvar_selec=find(sum(Rsel_matrix)>(0.25*nstab)); end
if (length(rvar_selec)==0) rvar_selec=rset; end
TrDat_rselec=TrDat(:,rvar_selec);
TeDat_rselec=TeDat(:,rvar_selec);
Model3 = fitcecoc(TrDat_rselec,TrLab_perm)
PredLab2(:,perm)=predict(Model2,TeDat_r) %* (Here, it indicates the error: Unable to perform assignment because the indices on the left side are not compatible with the size of the right side)
PredLab3(:,perm)=predict(Model3,TeDat_rselecI’m run this script. Could someone help me
rvar_selec=find(sum(Rsel_matrix)>=(ncut)); if (length(rvar_selec)==0) rvar_selec=find(sum(Rsel_matrix)>(0.25*nstab)); end
if (length(rvar_selec)==0) rvar_selec=rset; end
TrDat_rselec=TrDat(:,rvar_selec);
TeDat_rselec=TeDat(:,rvar_selec);
Model3 = fitcecoc(TrDat_rselec,TrLab_perm)
PredLab2(:,perm)=predict(Model2,TeDat_r) %* (Here, it indicates the error: Unable to perform assignment because the indices on the left side are not compatible with the size of the right side)
PredLab3(:,perm)=predict(Model3,TeDat_rselec I’m run this script. Could someone help me
rvar_selec=find(sum(Rsel_matrix)>=(ncut)); if (length(rvar_selec)==0) rvar_selec=find(sum(Rsel_matrix)>(0.25*nstab)); end
if (length(rvar_selec)==0) rvar_selec=rset; end
TrDat_rselec=TrDat(:,rvar_selec);
TeDat_rselec=TeDat(:,rvar_selec);
Model3 = fitcecoc(TrDat_rselec,TrLab_perm)
PredLab2(:,perm)=predict(Model2,TeDat_r) %* (Here, it indicates the error: Unable to perform assignment because the indices on the left side are not compatible with the size of the right side)
PredLab3(:,perm)=predict(Model3,TeDat_rselec unable to perform assignment because the indices o MATLAB Answers — New Questions
MATLAB Function always infers outputs as doubles
First, context: I’m attempting to generate HDL code from a Simulink model, which includes a MATLAB Function block. The relevant function is:
function [output, valid] = demux(input)
%#codegen
num_outputs = 24;
% Memory element: demultiplexed outputs
persistent demuxed;
if isempty(demuxed)
demuxed = zeros(num_outputs, 1, ‘like’, input);
end
% Assign from "input" to a single element of "demuxed" here… trimmed for length
% Commit actual values
output = demuxed(1:num_outputs, 1);
In my Simulink model, both input and output are sfix24_En23 types (fixed-point, signed, 24 bits total, 23 bits fractional):
I’ve tried to hint to MATLAB that output should be fixed-point as well, even including this line at the beginning of the function:
output = fi(zeros(num_outputs, 1), true, 24, 23);
This explicitly includes my fixed-point parameters, which isn’t great for maintainability, but would be acceptable for now in order to allow the model to compile.
However, in this and every other case I’ve tested, the Simulink console complains that Inferred type (‘double’) for data ‘output’ does not match back propagated type (’embedded.fi (sfix24_En23)’) from Simulink. Is there a way to make MATLAB realize that the output isn’t actually a double?First, context: I’m attempting to generate HDL code from a Simulink model, which includes a MATLAB Function block. The relevant function is:
function [output, valid] = demux(input)
%#codegen
num_outputs = 24;
% Memory element: demultiplexed outputs
persistent demuxed;
if isempty(demuxed)
demuxed = zeros(num_outputs, 1, ‘like’, input);
end
% Assign from "input" to a single element of "demuxed" here… trimmed for length
% Commit actual values
output = demuxed(1:num_outputs, 1);
In my Simulink model, both input and output are sfix24_En23 types (fixed-point, signed, 24 bits total, 23 bits fractional):
I’ve tried to hint to MATLAB that output should be fixed-point as well, even including this line at the beginning of the function:
output = fi(zeros(num_outputs, 1), true, 24, 23);
This explicitly includes my fixed-point parameters, which isn’t great for maintainability, but would be acceptable for now in order to allow the model to compile.
However, in this and every other case I’ve tested, the Simulink console complains that Inferred type (‘double’) for data ‘output’ does not match back propagated type (’embedded.fi (sfix24_En23)’) from Simulink. Is there a way to make MATLAB realize that the output isn’t actually a double? First, context: I’m attempting to generate HDL code from a Simulink model, which includes a MATLAB Function block. The relevant function is:
function [output, valid] = demux(input)
%#codegen
num_outputs = 24;
% Memory element: demultiplexed outputs
persistent demuxed;
if isempty(demuxed)
demuxed = zeros(num_outputs, 1, ‘like’, input);
end
% Assign from "input" to a single element of "demuxed" here… trimmed for length
% Commit actual values
output = demuxed(1:num_outputs, 1);
In my Simulink model, both input and output are sfix24_En23 types (fixed-point, signed, 24 bits total, 23 bits fractional):
I’ve tried to hint to MATLAB that output should be fixed-point as well, even including this line at the beginning of the function:
output = fi(zeros(num_outputs, 1), true, 24, 23);
This explicitly includes my fixed-point parameters, which isn’t great for maintainability, but would be acceptable for now in order to allow the model to compile.
However, in this and every other case I’ve tested, the Simulink console complains that Inferred type (‘double’) for data ‘output’ does not match back propagated type (’embedded.fi (sfix24_En23)’) from Simulink. Is there a way to make MATLAB realize that the output isn’t actually a double? codegen, fixed-point MATLAB Answers — New Questions
How to add a folder permanently to matlab path?
I am using addpath to add specified folders to matlab path, but it removes the folders from the matlab path everytime the application closes. I want to add that particular folder *permanently* to matlab path, so that I don’t have to add it again everytime i run the application. How can it be done??
Any help is appreciated.I am using addpath to add specified folders to matlab path, but it removes the folders from the matlab path everytime the application closes. I want to add that particular folder *permanently* to matlab path, so that I don’t have to add it again everytime i run the application. How can it be done??
Any help is appreciated. I am using addpath to add specified folders to matlab path, but it removes the folders from the matlab path everytime the application closes. I want to add that particular folder *permanently* to matlab path, so that I don’t have to add it again everytime i run the application. How can it be done??
Any help is appreciated. addpath, genpath MATLAB Answers — New Questions
License Institutional Student Federal?
I have an institutional account and I wanted to know how do I get a license to use MATLAB? I am a student at the Federal Institute of Southern Minas Gerais.I have an institutional account and I wanted to know how do I get a license to use MATLAB? I am a student at the Federal Institute of Southern Minas Gerais. I have an institutional account and I wanted to know how do I get a license to use MATLAB? I am a student at the Federal Institute of Southern Minas Gerais. student MATLAB Answers — New Questions
Error while compiling code with embedded coder support package for STM32
Hello, As part of my master thesis I created a closed loop motor control system with acceleration sensor as input and was in the phase of testing when suddenly i started getting this error below
DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 @Motor_initialization_comp.rsp -o "rtiostream_serial.o" "C:/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/shared/supportpackages/stm32/src/rtiostream_serial.c" C:/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/shared/supportpackages/stm32/src/rtiostream_serial.c:10:10: fatal error: rtiostream.h: No such file or directory 10 | #include "rtiostream.h" | ^~~~~~~~~~~~~~ compilation terminated. gmake: *** [rtiostream_serial.o] Error 1 C:UsersSanathDesktopmaster thesismaster thesis modelMotor_initialization_ert_rtw>echo The make command returned an error of 2 The make command returned an error of 2 C:UsersSanathDesktopmaster thesismaster thesis modelMotor_initialization_ert_rtw>exit /B 1 ### Build procedure for Motor_initialization aborted due to an error.
I have never faced this error and it suddenly started to appear. Moments ago i had compiled a code and it did not have any issues, can anyone suggest how to solve this issue?Hello, As part of my master thesis I created a closed loop motor control system with acceleration sensor as input and was in the phase of testing when suddenly i started getting this error below
DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 @Motor_initialization_comp.rsp -o "rtiostream_serial.o" "C:/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/shared/supportpackages/stm32/src/rtiostream_serial.c" C:/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/shared/supportpackages/stm32/src/rtiostream_serial.c:10:10: fatal error: rtiostream.h: No such file or directory 10 | #include "rtiostream.h" | ^~~~~~~~~~~~~~ compilation terminated. gmake: *** [rtiostream_serial.o] Error 1 C:UsersSanathDesktopmaster thesismaster thesis modelMotor_initialization_ert_rtw>echo The make command returned an error of 2 The make command returned an error of 2 C:UsersSanathDesktopmaster thesismaster thesis modelMotor_initialization_ert_rtw>exit /B 1 ### Build procedure for Motor_initialization aborted due to an error.
I have never faced this error and it suddenly started to appear. Moments ago i had compiled a code and it did not have any issues, can anyone suggest how to solve this issue? Hello, As part of my master thesis I created a closed loop motor control system with acceleration sensor as input and was in the phase of testing when suddenly i started getting this error below
DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 @Motor_initialization_comp.rsp -o "rtiostream_serial.o" "C:/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/shared/supportpackages/stm32/src/rtiostream_serial.c" C:/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/shared/supportpackages/stm32/src/rtiostream_serial.c:10:10: fatal error: rtiostream.h: No such file or directory 10 | #include "rtiostream.h" | ^~~~~~~~~~~~~~ compilation terminated. gmake: *** [rtiostream_serial.o] Error 1 C:UsersSanathDesktopmaster thesismaster thesis modelMotor_initialization_ert_rtw>echo The make command returned an error of 2 The make command returned an error of 2 C:UsersSanathDesktopmaster thesismaster thesis modelMotor_initialization_ert_rtw>exit /B 1 ### Build procedure for Motor_initialization aborted due to an error.
I have never faced this error and it suddenly started to appear. Moments ago i had compiled a code and it did not have any issues, can anyone suggest how to solve this issue? embedded coder, simulink, control, electric_motor_control, digital signal processing, embedded matlab function MATLAB Answers — New Questions
how to set different axis value?
I want to change the axis display value in a contour plot.
xylim = 0.0055 ;
N = 5; x = linspace(-xylim,xylim,N); y = x;
[X,Y] = meshgrid(x,y);
r = (X.^2 + Y.^2); rho = sqrt(r);
f = 0.011 ;
theta = atan(rho./f) ;
CPhi = X./rho; SPhi = Y./rho;
if mod(N,2) == 1
CPhi((N-1)/2+1,(N-1)/2+1) = 1;
SPhi((N-1)/2+1,(N-1)/2+1) = 0;
end
%% Function
n1 = 1;
n2 = 1.5 ;
thetaI = theta;
Th = theta*180/pi;
thetaT = asin((n1./n2).*sin(thetaI));
CTi = cos(thetaI);
CTt = cos(thetaT);
a = (n2.*CTi – n1.*CTt) ;
b = (n2.*CTi + n1.*CTt) ;
c = (n1.*CTi – n2.*CTt) ;
d = (n1.*CTi + n2.*CTt) ;
Rp = a./b;
Rs = c./d;
figure,contourf(X,Y,Rp,20);
Now the x and y axis has value -5 to +5 mm, from the below image we can see. I want to change the axis value from X and Y to the value of the red cross line of the Th value chart(below image) which is a function of X and Y. So new x axis should be [26.5651 14.0362 0 140362 26.5651} and new y axis [26.5651 14.0362 0 140362 26.5651}. can anyone help me please? Thank you.I want to change the axis display value in a contour plot.
xylim = 0.0055 ;
N = 5; x = linspace(-xylim,xylim,N); y = x;
[X,Y] = meshgrid(x,y);
r = (X.^2 + Y.^2); rho = sqrt(r);
f = 0.011 ;
theta = atan(rho./f) ;
CPhi = X./rho; SPhi = Y./rho;
if mod(N,2) == 1
CPhi((N-1)/2+1,(N-1)/2+1) = 1;
SPhi((N-1)/2+1,(N-1)/2+1) = 0;
end
%% Function
n1 = 1;
n2 = 1.5 ;
thetaI = theta;
Th = theta*180/pi;
thetaT = asin((n1./n2).*sin(thetaI));
CTi = cos(thetaI);
CTt = cos(thetaT);
a = (n2.*CTi – n1.*CTt) ;
b = (n2.*CTi + n1.*CTt) ;
c = (n1.*CTi – n2.*CTt) ;
d = (n1.*CTi + n2.*CTt) ;
Rp = a./b;
Rs = c./d;
figure,contourf(X,Y,Rp,20);
Now the x and y axis has value -5 to +5 mm, from the below image we can see. I want to change the axis value from X and Y to the value of the red cross line of the Th value chart(below image) which is a function of X and Y. So new x axis should be [26.5651 14.0362 0 140362 26.5651} and new y axis [26.5651 14.0362 0 140362 26.5651}. can anyone help me please? Thank you. I want to change the axis display value in a contour plot.
xylim = 0.0055 ;
N = 5; x = linspace(-xylim,xylim,N); y = x;
[X,Y] = meshgrid(x,y);
r = (X.^2 + Y.^2); rho = sqrt(r);
f = 0.011 ;
theta = atan(rho./f) ;
CPhi = X./rho; SPhi = Y./rho;
if mod(N,2) == 1
CPhi((N-1)/2+1,(N-1)/2+1) = 1;
SPhi((N-1)/2+1,(N-1)/2+1) = 0;
end
%% Function
n1 = 1;
n2 = 1.5 ;
thetaI = theta;
Th = theta*180/pi;
thetaT = asin((n1./n2).*sin(thetaI));
CTi = cos(thetaI);
CTt = cos(thetaT);
a = (n2.*CTi – n1.*CTt) ;
b = (n2.*CTi + n1.*CTt) ;
c = (n1.*CTi – n2.*CTt) ;
d = (n1.*CTi + n2.*CTt) ;
Rp = a./b;
Rs = c./d;
figure,contourf(X,Y,Rp,20);
Now the x and y axis has value -5 to +5 mm, from the below image we can see. I want to change the axis value from X and Y to the value of the red cross line of the Th value chart(below image) which is a function of X and Y. So new x axis should be [26.5651 14.0362 0 140362 26.5651} and new y axis [26.5651 14.0362 0 140362 26.5651}. can anyone help me please? Thank you. set axis, set axis value, contour plot MATLAB Answers — New Questions
Why is my 3D Projectile Trajectory not being calculated properly?
% Constants
g = 9.81; % gravity
v0 = 50; % initial velocity
% Time
t = linspace(0, 5, 100); % time from 0 to 5 seconds
% Elevation and Azimuth angles
elevation = pi/4; % initial elevation angle (angle above the xz plane)
azimuth = pi/4; % initial azimuth angle (angle from the positive x-axis, counterclockwise)
% Calculate positions
x = v0 * t * cos(elevation) * cos(azimuth);
y = v0 * t * sin(elevation) – 0.5 * g * t.^2;
z = v0 * t * cos(elevation) * sin(azimuth);
% Plot 3D trajectory
figure;
plot3(x, y, z, ‘LineWidth’, 2);
xlabel(‘X’);
ylabel(‘Y’);
zlabel(‘Z’);
title(‘3D Artillery Simulation’);
grid on;% Constants
g = 9.81; % gravity
v0 = 50; % initial velocity
% Time
t = linspace(0, 5, 100); % time from 0 to 5 seconds
% Elevation and Azimuth angles
elevation = pi/4; % initial elevation angle (angle above the xz plane)
azimuth = pi/4; % initial azimuth angle (angle from the positive x-axis, counterclockwise)
% Calculate positions
x = v0 * t * cos(elevation) * cos(azimuth);
y = v0 * t * sin(elevation) – 0.5 * g * t.^2;
z = v0 * t * cos(elevation) * sin(azimuth);
% Plot 3D trajectory
figure;
plot3(x, y, z, ‘LineWidth’, 2);
xlabel(‘X’);
ylabel(‘Y’);
zlabel(‘Z’);
title(‘3D Artillery Simulation’);
grid on; % Constants
g = 9.81; % gravity
v0 = 50; % initial velocity
% Time
t = linspace(0, 5, 100); % time from 0 to 5 seconds
% Elevation and Azimuth angles
elevation = pi/4; % initial elevation angle (angle above the xz plane)
azimuth = pi/4; % initial azimuth angle (angle from the positive x-axis, counterclockwise)
% Calculate positions
x = v0 * t * cos(elevation) * cos(azimuth);
y = v0 * t * sin(elevation) – 0.5 * g * t.^2;
z = v0 * t * cos(elevation) * sin(azimuth);
% Plot 3D trajectory
figure;
plot3(x, y, z, ‘LineWidth’, 2);
xlabel(‘X’);
ylabel(‘Y’);
zlabel(‘Z’);
title(‘3D Artillery Simulation’);
grid on; projectile, physics, azimuth, elevation, launch angle MATLAB Answers — New Questions
Bayesian Time varying coefficient model
(This is more general econometric question) While I am writing a thesis on how the cyclicality of fiscal policy evolve over time in certain countries using Bayesian time varying regression. There are some questions that I would like to ask.
I know that Bayesian regression requires prior distribution (which is chosen by the model maker) and I have no idea what the prior distribution should be. Should I use non-informative prior?
How does Bayesian time varying regression really works? Is it similar to rolling window method in normal regression or is there a method where I can do time varying coefficient model in Bayesian regression?(This is more general econometric question) While I am writing a thesis on how the cyclicality of fiscal policy evolve over time in certain countries using Bayesian time varying regression. There are some questions that I would like to ask.
I know that Bayesian regression requires prior distribution (which is chosen by the model maker) and I have no idea what the prior distribution should be. Should I use non-informative prior?
How does Bayesian time varying regression really works? Is it similar to rolling window method in normal regression or is there a method where I can do time varying coefficient model in Bayesian regression? (This is more general econometric question) While I am writing a thesis on how the cyclicality of fiscal policy evolve over time in certain countries using Bayesian time varying regression. There are some questions that I would like to ask.
I know that Bayesian regression requires prior distribution (which is chosen by the model maker) and I have no idea what the prior distribution should be. Should I use non-informative prior?
How does Bayesian time varying regression really works? Is it similar to rolling window method in normal regression or is there a method where I can do time varying coefficient model in Bayesian regression? bayesian linear regression, time varying coefficient MATLAB Answers — New Questions
When this code is executed, 36 separate windows will open. I want the result to be displayed in a window.
I want the output to be similar to this image.I want the output to be similar to this image. I want the output to be similar to this image. plot, 3d plots, display, plotting MATLAB Answers — New Questions
How to define geographicGrid in matlab code?
I am using following matlab code to extract data but it is giving some error.
img_file = ‘c:data4MARCH24_BAND7_SUBSET.dat’
img = hypercube(img_file);
shapefile = ‘c:dataAchi Khurd.shp’;
S = shaperead(shapefile);
%remove small triangles and squares
coord_lengths = arrayfun(@(s) numel(s.X), S);
not_useful_mask = coord_lengths < 10;
S(not_useful_mask) = [];
polygon = polyshape({S.X}, {S.Y});
% Create a logical mask
[Z,R] = readgeoraster(img_file);
[lat,lon] = geographicGrid(R);
[Lon, Lat] = meshgrid(lon, lat);
logical_mask = reshape(isinterior(polygon, Lon(:), Lat(:)), size(Lon));
% Use the logical mask to extract data
extracted_data = img(logical_mask);
disp(extracted_data);
It is giving following error
Incorrect number or types of inputs or outputs for function geographicGrid.
Error in Test (line 14)
[lat,lon] = geographicGrid(R);
I am attaching the data also in order to run the above mentioned matlab code.
I would be thankful for suggesting me to fix it.
DevaI am using following matlab code to extract data but it is giving some error.
img_file = ‘c:data4MARCH24_BAND7_SUBSET.dat’
img = hypercube(img_file);
shapefile = ‘c:dataAchi Khurd.shp’;
S = shaperead(shapefile);
%remove small triangles and squares
coord_lengths = arrayfun(@(s) numel(s.X), S);
not_useful_mask = coord_lengths < 10;
S(not_useful_mask) = [];
polygon = polyshape({S.X}, {S.Y});
% Create a logical mask
[Z,R] = readgeoraster(img_file);
[lat,lon] = geographicGrid(R);
[Lon, Lat] = meshgrid(lon, lat);
logical_mask = reshape(isinterior(polygon, Lon(:), Lat(:)), size(Lon));
% Use the logical mask to extract data
extracted_data = img(logical_mask);
disp(extracted_data);
It is giving following error
Incorrect number or types of inputs or outputs for function geographicGrid.
Error in Test (line 14)
[lat,lon] = geographicGrid(R);
I am attaching the data also in order to run the above mentioned matlab code.
I would be thankful for suggesting me to fix it.
Deva I am using following matlab code to extract data but it is giving some error.
img_file = ‘c:data4MARCH24_BAND7_SUBSET.dat’
img = hypercube(img_file);
shapefile = ‘c:dataAchi Khurd.shp’;
S = shaperead(shapefile);
%remove small triangles and squares
coord_lengths = arrayfun(@(s) numel(s.X), S);
not_useful_mask = coord_lengths < 10;
S(not_useful_mask) = [];
polygon = polyshape({S.X}, {S.Y});
% Create a logical mask
[Z,R] = readgeoraster(img_file);
[lat,lon] = geographicGrid(R);
[Lon, Lat] = meshgrid(lon, lat);
logical_mask = reshape(isinterior(polygon, Lon(:), Lat(:)), size(Lon));
% Use the logical mask to extract data
extracted_data = img(logical_mask);
disp(extracted_data);
It is giving following error
Incorrect number or types of inputs or outputs for function geographicGrid.
Error in Test (line 14)
[lat,lon] = geographicGrid(R);
I am attaching the data also in order to run the above mentioned matlab code.
I would be thankful for suggesting me to fix it.
Deva how to define geographicgrid in matlab code? MATLAB Answers — New Questions
Saving 3D image after segmentation
I have a 3D image rock that I preformed segmentation on using this code
RA = imread(‘BB258_6_A_2um_1600x3_8bit.tif’);
threshold_calc = multithresh(RA, 2); %two is the number of thresholds so we are expecting to have 3 classes
image_segmented = imquantize(RA, threshold_calc);
imshow(image_segmented , []);
what I want to do is to save the 3D image as tif can you please help meI have a 3D image rock that I preformed segmentation on using this code
RA = imread(‘BB258_6_A_2um_1600x3_8bit.tif’);
threshold_calc = multithresh(RA, 2); %two is the number of thresholds so we are expecting to have 3 classes
image_segmented = imquantize(RA, threshold_calc);
imshow(image_segmented , []);
what I want to do is to save the 3D image as tif can you please help me I have a 3D image rock that I preformed segmentation on using this code
RA = imread(‘BB258_6_A_2um_1600x3_8bit.tif’);
threshold_calc = multithresh(RA, 2); %two is the number of thresholds so we are expecting to have 3 classes
image_segmented = imquantize(RA, threshold_calc);
imshow(image_segmented , []);
what I want to do is to save the 3D image as tif can you please help me save, image processing, image segmentation MATLAB Answers — New Questions
I am recieving an error in creating the solution however it still prints a result.
clc
clear all
close all
%Homework 7 Question 3
Tin=298; %K
Cp=80; %J/(mol K)
CAin=2000; %mol/m^3
k0=10e-7; %m3/(mol min)
Ea_R=5000; %K
rho=1000; %mol/m^3
CA=linspace(2,2000,61);
xA=(CAin-CA)/CAin;
T_sol=zeros(1,length(CA));
k_sol=zeros(1,length(CA));
tau_sol=zeros(1,length(CA));
DHR=-50000; %J/mol exothermic (gets hot)
for i=1:length(CA)
syms T k tau
eqn1=k==k0*exp((-Ea_R)*((1/T)-(1/Tin)));
eqn2=2*k*(CA(i)^2)==(CAin-CA(i))/tau;
eqn3=k*tau*(CA(i))^2*DHR==rho*Cp*(Tin-T);
solution=solve([eqn1,eqn2,eqn3],[T,k,tau]);
T_sol(i)=double(solution.T);
k_sol(i)=double(solution.k);
tau_sol(i)=double(solution.tau);
end
figure(1)
plot(log10(tau_sol),xA,’-bo’);
xlabel(‘log_{10}(tau, min)’)
ylabel(‘x_A’)clc
clear all
close all
%Homework 7 Question 3
Tin=298; %K
Cp=80; %J/(mol K)
CAin=2000; %mol/m^3
k0=10e-7; %m3/(mol min)
Ea_R=5000; %K
rho=1000; %mol/m^3
CA=linspace(2,2000,61);
xA=(CAin-CA)/CAin;
T_sol=zeros(1,length(CA));
k_sol=zeros(1,length(CA));
tau_sol=zeros(1,length(CA));
DHR=-50000; %J/mol exothermic (gets hot)
for i=1:length(CA)
syms T k tau
eqn1=k==k0*exp((-Ea_R)*((1/T)-(1/Tin)));
eqn2=2*k*(CA(i)^2)==(CAin-CA(i))/tau;
eqn3=k*tau*(CA(i))^2*DHR==rho*Cp*(Tin-T);
solution=solve([eqn1,eqn2,eqn3],[T,k,tau]);
T_sol(i)=double(solution.T);
k_sol(i)=double(solution.k);
tau_sol(i)=double(solution.tau);
end
figure(1)
plot(log10(tau_sol),xA,’-bo’);
xlabel(‘log_{10}(tau, min)’)
ylabel(‘x_A’) clc
clear all
close all
%Homework 7 Question 3
Tin=298; %K
Cp=80; %J/(mol K)
CAin=2000; %mol/m^3
k0=10e-7; %m3/(mol min)
Ea_R=5000; %K
rho=1000; %mol/m^3
CA=linspace(2,2000,61);
xA=(CAin-CA)/CAin;
T_sol=zeros(1,length(CA));
k_sol=zeros(1,length(CA));
tau_sol=zeros(1,length(CA));
DHR=-50000; %J/mol exothermic (gets hot)
for i=1:length(CA)
syms T k tau
eqn1=k==k0*exp((-Ea_R)*((1/T)-(1/Tin)));
eqn2=2*k*(CA(i)^2)==(CAin-CA(i))/tau;
eqn3=k*tau*(CA(i))^2*DHR==rho*Cp*(Tin-T);
solution=solve([eqn1,eqn2,eqn3],[T,k,tau]);
T_sol(i)=double(solution.T);
k_sol(i)=double(solution.k);
tau_sol(i)=double(solution.tau);
end
figure(1)
plot(log10(tau_sol),xA,’-bo’);
xlabel(‘log_{10}(tau, min)’)
ylabel(‘x_A’) error, chemical reactor MATLAB Answers — New Questions