Pull up a chair!

Discussions is your place to get to know your peers, tackle the bigger challenges together, and have fun along the way.

  • Want to see the latest updates? Follow the Highlights!
  • Looking for techniques improve your MATLAB or Simulink skills? Tips & Tricks has you covered!
  • Sharing the perfect math joke, pun, or meme? Look no further than Fun!
  • Think there's a channel we need? Tell us more in Ideas


Hi, I'm trying to analyze a .vtk data set from MRI. I already calculate the kinetic energy. Now I'm trying to calculate the viscous energy loss but the result that I found does not respect the reality so I think that I'm doing something wrong.
Can someone help me with this?
%% FUNCTION
function energy_loss = calculateViscousEnergyLossForAllPhases(MRI_Velocity, dynamic_viscosity,interval)
% Preallocate the energy_dissipation array
energy_loss = zeros(1, 30);
for idx_phase = 1:30
% Velocity field
vel_x = MRI_Velocity{1, idx_phase}.velocity(:,1) * 1e-2; % Velocity in X from cm/s to m/s
vel_y = MRI_Velocity{1, idx_phase}.velocity(:,2) * 1e-2; % Velocity in Y in m/s
vel_z = MRI_Velocity{1, idx_phase}.velocity(:,3) * 1e-2; % Velocity in Z in m/s
% Coordinates
x = MRI_Velocity{1, idx_phase}.points(:,1) * 1e-3; % from mm to m
y = MRI_Velocity{1, idx_phase}.points(:,2) * 1e-3;
z = MRI_Velocity{1, idx_phase}.points(:,3) * 1e-3;
% Compute partial derivatives
dUdx = gradient(vel_x, x, 1);
dUdy = gradient(vel_x, y, 2);
dUdz = gradient(vel_x, z, 3);
dVdx = gradient(vel_y, x, 1);
dVdy = gradient(vel_y, y, 2);
dVdz = gradient(vel_y, z, 3);
dWdx = gradient(vel_z, x, 1);
dWdy = gradient(vel_z, y, 2);
dWdz = gradient(vel_z, z, 3);
% Calculate energy dissipation
ED = 2 * (dUdx.^2 + dUdy.^2 + dUdz.^2) + ...
2 * (dVdx.^2 + dVdy.^2 + dVdz.^2) + ...
2 * (dWdx.^2 + dWdy.^2 + dWdz.^2) + ...
(dUdz + dWdx).^2 + (dVdx + dUdy).^2 + (dWdy + dVdz).^2;
% Scale by dynamic viscosity of fluid and store
energy_loss(idx_phase) = sum(ED, 'all', 'omitnan') * dynamic_viscosity * interval.^3;
end
end
%% CODE
dynamic_viscosity_blood = 0.0039;
% human dynamic_viscosity_blood from 0.003 to 0.004; % Approximate value for blood at body temperature
% Call the function to calculate viscous energy loss for blood flow for all phases
energy_loss_RV_J = calculateViscousEnergyLossForAllPhases(MRI_Velocity_RV, dynamic_viscosity_blood,interval/1000);
energy_loss_LV_J = calculateViscousEnergyLossForAllPhases(MRI_Velocity_LV, dynamic_viscosity_blood,interval/1000);
% From Joule to milliwatt (mW)
energy_loss_RV_mW = energy_loss_RV_J.*1e3;
energy_loss_LV_mW = energy_loss_LV_J.*1e3;
figure
plot(time, energy_loss_RV_mW, 'r','LineWidth',1.5);
hold on
plot(time, energy_loss_LV_mW,'b','LineWidth',1.5);
title('Viscous energy loss over Cycle','FontSize',14);
xlabel('Cycle','FontSize',12);
ylabel('Viscous energy loss [mW]','FontSize',12);
legend('RV','LV')
Hi Guys
Posting this based on a thought I had, so I don't really ahve any code however I would like to know if the thought process is correct and/or relatively accurate.
Consider a simple spring mass system which only allows compression on the spring however when there is tension the mass should move without the effect of the spring distrupting it, thus the mass is just thrown vertically upwards.
The idea which I came up with for such a system is to have two sets of dfferential equations, one which represents the spring system and another which presents a mass in motion without the effects of the spring.
Please refer to the below basic outline of the code which I am proposing. I believe that this may produce relatively decent results. The code essentially checks if there is tension in the system if there is it then takes the last values from the spring mass differential equation and uses it as initial conditions for the differential equation with the mass moving wothout the effects of the spring, this process works in reverse also. The error which would exist is that the initial conditions applied to the system would include effects of the spring. Would there be a better way to code such behaviour?
function xp = statespace(t,x,f,c,k,m)
if (k*x(1)) positive #implying tension
**Use last time step as initial conditions**
**differential equation of a mass moving""
end
if x(1) negative #implying that the mass in now moving down therefore compression in spring
**Use last time step as initial conditions**
**differential equation for a spring mass system**
end
end
Hi Friends,
I'm looking for a matlab program which calculat deflection of simply supported tapered beam under uniform travers load.
Thank you for your help.
Hello,
I have an equation model following a law of type power: s=aN^b
For the measure equation, I have also a power law: m=cN^d
So I would like to have an extended Kalman Filter code in Matlab for this case. CAN YOU HELP ME PLEASE ?
Hello.
I use readgeoraster to read in a 25MB geotiff. I then turn around and immediately write out the data with geotiffwrite. The resultant file is now 250MB.
What is the explanation for this 10x increase in file size? The data read in are 'single' format. And that is the exact data I am writing out.
Dave
Seeing a colleague make this mistake (one I've had to fix multiple times in other's work too) makes me want to ask the community: would you like the awgn() function/blocks to give the option for creating a SNR at the bandwidth of the signal? Your typical flow is something like this:
  • Create a signal, usually at some nominal upsampling factor (e.g., 4) such that it's now nicely over sampled, especially if you're using a RRC or similar pulse shaping filter.
  • Potentially add a frequency offset (which might make the sample frequency even higher)
  • Add AWGN channel model for a desired SNR
  • Put this into your detector/receiver model
The problem is, when someone says, "I'm detecting XYZ at foo SNR," it should not magically improve as a function of the oversample. The problem isn't that awgn() generates white noise, that's what it's supposed to do and the typical receiver has noise across the entire band. The problem is that SNR is most properly defined as the signal power over the noise power spectral density times the signal's noise equivalent bandwidth. Now I looked and there's no handy function for computing NEBW for an input signal (there's just a function for assessing analysis windows). In practice it can get a bit tricky. The occupied bandwidth or HPBW are often close enough to the NEBW, we're usually not haggling over hundredths of a dB. So, in my not so humble opinion, the "measured" flag for awgn() should give an option for bandwidth matching or at least document the behavior better in the help page. All too often I'm seeing 3-6 (or worse) dB errors because people aren't taking the signal's bandwidth into account.
Unlike last year's contest, there are some new technologies this year that might offer some advantages. Namely generative AI's like ChatGPT, Bard, etc. Not to be excluded, MathWorks just launched the AI Chat Playground :)
The MATLAB AI Chat Playground is open to everyone!
Check it out here on the community: https://www.mathworks.com/matlabcentral/playground
MATLAB AI Chat Playground Screenshot
I just published a blog post announcing the release.
Christine
Christine
Posted on 7 Nov 2023 at 14:22

i need to create an app in app designer that is able to convert ac to dc. i already created the layout of the app and i created a curcuit that is able to convert ac to dc in sumilink. but i am having troubles linking the circuit simulation to the app.
Basically, i want the user to input the voltage in the app and it should send that data to the simulation and the output should come back to the app.
When I apply genetic algorithm to find the optimal parameter, before the parameter enters the algorithm, I have controlled the parameter to keep two decimals in their respective ranges, but when the final output, the optimal parameter returned is really six decimals. Why? What am I supposed to do? (Note: I need to keep two decimal places in the parameter before entering the algorithm, because a change of 0.001 in the parameter has a great effect on the result, so I can't round the result directly.)Look forward to your reply~
LAWAN HARUNA
LAWAN HARUNA
Posted on 6 Nov 2023 at 15:36

good afternoon everyone my name is Dundu lawan haruna ,i'm a final year student at the department of computer engineering ABU Zaria, Nigerian , and i wanted to do my final year project based on computer vision : project topic , designing an eye glasses to help those people with visual imparement to be able to navigate enviroment efficiently , that's why i need a support from you guys ,all advised are highly well come , thank you for your support.
Willis
Willis
Posted on 5 Nov 2023 at 15:59

Can anyone kindly assist me in this topic
You are invited to join our 2023 community contest – MATLAB Flipbook Mini Hack! This year’s contest revolves around creating interesting animations using MATLAB.
Whether you are a seasoned MATLAB user or just getting started, this contest offers a fantastic opportunity to showcase your skills, learn from others, and engage with the vibrant MATLAB Central community.
Timeframe
This contest runs for 4 weeks from Nov. 6th to Dec. 3rd.
How to play
  • Create a new animation or remix an existing one with up to 2,000 characters of code.
  • Simply vote on the animations you love!
Prizes
You will have opportunities to win compelling prizes, including Amazon gift cards, MathWorks T-shirts, and virtual badges. We will give out both weekly prizes and grand prizes.
Interested?
The 1st step is to follow the contest so that you will get notified when the contest starts and winners are announced.
We look forward to seeing your creative contributions and witnessing the talent within our community.
The MATLAB Central Community team
Image Analyst
Image Analyst
Posted on 31 Oct 2023 at 15:26

Just in time for Halloween.
Here's a MATLAB class I wrote that leverages the MATLAB Central Interface for MATLAB toolbox, which in turn uses the publicy available Community API. Using this class, I've created a few Favorites that show me what's going on in MATLAB Central - without having to leave MATLAB 🙂
The class has a few convenient queries:
  • Results for the last 7 days
  • Results for the last 30 days
  • Results for the current month
  • Results for today
And supporting a bunch of different content scopes:
  • All MATLAB Central
  • MATLAB Answers
  • Blogs
  • Cody
  • Contests
  • File Exchange
  • Exclude Answers content
The results are displayed in the command window (which worked best for me) and link to each post. Here's what that looks like for this command
>> CommunityFeed.thisMonth("app designer", CommunityFeed.Scope.ExcludeAnswers)
Let me know if you find this class useful and feel free to suggest changes.

Good day community, can I know what is this symbol could be? It looks like a ramp/ continuous ramp. But I believe it is not both them. I saw someone connect it after a voltage/ current measurement. Can I know what is the function of this symbol too? Much appreciate for the answers given