matlab编程实践18、19

浅水方程


        浅水方程可以建立起海啸和浴缸中波浪的数学模型。浅水方程建立了水或者其它不可压缩液体受扰动时传播的模型。隐含的假设是,液体的深度和波浪的长度、扰动等相比是很小的。

         在这样的记号下,浅水方程为双曲守恒定律的一个例子。

\frac{\partial U}{\partial t}+\frac{\partial F(U)}{\partial x}+\frac{\partial G(U)}{\partial y}=0

        使用拉克斯-冯特洛夫方法计算方程的近似数值解。waterwave求解的区域为正方形区域,有反射的边界条件。在初始时刻,在整个区域都有h=1,u=0,v=0,这样解是静态的。然后在连续几个时间步长内,二维高斯型峰值添加到h处,用来模拟水滴滴到水面上的冲量扰动作用。

shading 设置颜色着色属性

function waterwave
% WATERWAVE   2D Shallow Water Model
%
% Lax-Wendroff finite difference method.
% Reflective boundary conditions.
% Random water drops initiate gravity waves.
% Surface plot displays height colored by momentum.
% Plot title shows t = simulated time and tv = a measure of total variation.
%t = 模拟时间,tv = 总变化量
% An exact solution to the conservation law would have constant tv.
% Lax-Wendroff produces nonphysical oscillations and increasing tv.
%
% See:
%    http://en.wikipedia.org/wiki/Shallow_water_equations
%    http://www.amath.washington.edu/~rjl/research/tsunamis
%    http://www.amath.washington.edu/~dgeorge/tsunamimodeling.html
%    http://www.amath.washington.edu/~claw/applications/shallow/www% Parametersn = 64;                  % grid size
g = 9.8;                 % gravitational constant
dt = 0.01;               % hardwired timestep
dx = 1.0;
dy = 1.0;
nplotstep = 8; %绘图间隔
ndrops = 1; % 最大滴数
dropstep = 200; % 液滴间隔
D = droplet(1.5,21); % 模拟水滴
% Initialize graphics[surfplot,top,restart,quit] = initgraphics(n); %启动图形% Outer loop, restarts.while get(quit,'value') == 0set(restart,'value',0)H = ones(n+2,n+2);   U = zeros(n+2,n+2);  V = zeros(n+2,n+2);Hx = zeros(n+1,n+1); Ux = zeros(n+1,n+1); Vx = zeros(n+1,n+1);Hy = zeros(n+1,n+1); Uy = zeros(n+1,n+1); Vy = zeros(n+1,n+1);ndrop = ceil(rand*ndrops);nstep = 0;% Inner loop, time steps.while get(restart,'value')==0 && get(quit,'value')==0nstep = nstep + 1;% Random water dropsif mod(nstep,dropstep) == 0 && nstep <= ndrop*dropstepw = size(D,1);i = ceil(rand*(n-w))+(1:w);j = ceil(rand*(n-w))+(1:w);H(i,j) = H(i,j) + (1+4*rand)/5*D;end% Reflective boundary conditionsH(:,1) = H(:,2);      U(:,1) = U(:,2);       V(:,1) = -V(:,2);H(:,n+2) = H(:,n+1);  U(:,n+2) = U(:,n+1);   V(:,n+2) = -V(:,n+1);H(1,:) = H(2,:);      U(1,:) = -U(2,:);      V(1,:) = V(2,:);H(n+2,:) = H(n+1,:);  U(n+2,:) = -U(n+1,:);  V(n+2,:) = V(n+1,:);% First half step% x directioni = 1:n+1;j = 1:n;% heightHx(i,j) = (H(i+1,j+1)+H(i,j+1))/2 - dt/(2*dx)*(U(i+1,j+1)-U(i,j+1));% x momentumUx(i,j) = (U(i+1,j+1)+U(i,j+1))/2 -  ...dt/(2*dx)*((U(i+1,j+1).^2./H(i+1,j+1) + g/2*H(i+1,j+1).^2) - ...(U(i,j+1).^2./H(i,j+1) + g/2*H(i,j+1).^2));% y momentumVx(i,j) = (V(i+1,j+1)+V(i,j+1))/2 - ...dt/(2*dx)*((U(i+1,j+1).*V(i+1,j+1)./H(i+1,j+1)) - ...(U(i,j+1).*V(i,j+1)./H(i,j+1)));% y directioni = 1:n;j = 1:n+1;% heightHy(i,j) = (H(i+1,j+1)+H(i+1,j))/2 - dt/(2*dy)*(V(i+1,j+1)-V(i+1,j));% x momentumUy(i,j) = (U(i+1,j+1)+U(i+1,j))/2 - ...dt/(2*dy)*((V(i+1,j+1).*U(i+1,j+1)./H(i+1,j+1)) - ...(V(i+1,j).*U(i+1,j)./H(i+1,j)));% y momentumVy(i,j) = (V(i+1,j+1)+V(i+1,j))/2 - ...dt/(2*dy)*((V(i+1,j+1).^2./H(i+1,j+1) + g/2*H(i+1,j+1).^2) - ...(V(i+1,j).^2./H(i+1,j) + g/2*H(i+1,j).^2));% Second half stepi = 2:n+1;j = 2:n+1;% heightH(i,j) = H(i,j) - (dt/dx)*(Ux(i,j-1)-Ux(i-1,j-1)) - ...(dt/dy)*(Vy(i-1,j)-Vy(i-1,j-1));% x momentumU(i,j) = U(i,j) - (dt/dx)*((Ux(i,j-1).^2./Hx(i,j-1) + g/2*Hx(i,j-1).^2) - ...(Ux(i-1,j-1).^2./Hx(i-1,j-1) + g/2*Hx(i-1,j-1).^2)) ...- (dt/dy)*((Vy(i-1,j).*Uy(i-1,j)./Hy(i-1,j)) - ...(Vy(i-1,j-1).*Uy(i-1,j-1)./Hy(i-1,j-1)));% y momentumV(i,j) = V(i,j) - (dt/dx)*((Ux(i,j-1).*Vx(i,j-1)./Hx(i,j-1)) - ...(Ux(i-1,j-1).*Vx(i-1,j-1)./Hx(i-1,j-1))) ...- (dt/dy)*((Vy(i-1,j).^2./Hy(i-1,j) + g/2*Hy(i-1,j).^2) - ...(Vy(i-1,j-1).^2./Hy(i-1,j-1) + g/2*Hy(i-1,j-1).^2));% Update plotif mod(nstep,nplotstep) == 0C = abs(U(i,j)) + abs(V(i,j));  % Color shows momemtumt = nstep*dt;tv = norm(C,'fro');set(surfplot,'zdata',H(i,j),'cdata',C);set(top,'string',sprintf('t = %6.2f,  tv = %6.2f',t,tv))drawnowendif all(all(isnan(H))), break, end  % Unstable, restartend
end
close(gcf)% ------------------------------------function D = droplet(height,width)
% DROPLET  2D Gaussian
% D = droplet(height,width)[x,y] = ndgrid(-1:(2/(width-1)):1);D = height*exp(-5*(x.^2+y.^2));% ------------------------------------function [surfplot,top,restart,quit] = initgraphics(n);
% INITGRAPHICS  Initialize graphics for waterwave.
% [surfplot,top,restart,quit] = initgraphics(n)
% returns handles to a surface plot, its title, and two uicontrol toggles.clfshgset(gcf,'numbertitle','off','name','Shallow_water')x = (0:n-1)/(n-1);surfplot = surf(x,x,ones(n,n),zeros(n,n));grid offaxis([0 1 0 1 -1 3])caxis([-1 1])shading facetedc = (1:64)'/64;cyan = [0*c c c];colormap(cyan)top = title('xxx');restart = uicontrol('position',[20 20 80 20],'style','toggle','string','restart');quit = uicontrol('position',[120 20 80 20],'style','toggle','string','close');


摩尔斯电码


        摩尔斯电码演示了二元树(binary tree)单元数组(cell array)。电码由短的点(dot或‘.’)或者长的停顿(dash或‘-’)分隔。

        '...---...'表示SOS,‘...--...’表示SMS。


摩尔斯树


        采用二元树来定义摩尔斯电码。从根节点开始向左移动一个链接表示一个“点”,向右表示一个“划”。如可以用“.-”来表示字母A。

 

function M = morse_tree
% MORSE_TREE
% M = morse_tree is a cell array of cell arrays, the binary
% tree for the Morse code of the 26 Latin characters.
%
% M = morse_tree_extended is a larger cell array of cell arrays,
% the binary tree for the Morse code of the 26 Latin characters
% plus digits, punctuation marks, and several non-Latin characters.
%
%                     _____  root _____
%                   /                   \
%               _ E _                   _ T _
%            /         \             /         \
%           I           A           N           M
%         /   \       /   \       /   \       /   \
%        S     U     R     W     D     K     G     O
%       / \   /     /     / \   / \   / \   / \
%      H   V F     L     P   J B   X C   Y Z   Q
%global extend
if extend==1M = morse_tree_extended;return
end% Level 4
h = {'H' {} {}};
v = {'V' {} {}};
f = {'F' {} {}};
l = {'L' {} {}};
p = {'P' {} {}};
j = {'J' {} {}};
b = {'B' {} {}};
x = {'X' {} {}};
c = {'C' {} {}};
y = {'Y' {} {}};
z = {'Z' {} {}};
q = {'Q' {} {}};% Level 3
s = {'S' h v};
u = {'U' f {}};
r = {'R' l {}};
w = {'W' p j};
d = {'D' b x};
k = {'K' c y};
g = {'G' z q};
o = {'O' {} {}};% Level 2
i = {'I' s u};
a = {'A' r w};
n = {'N' d k};
m = {'M' g o};% Level 1
e = {'E' i a};
t = {'T' n m};% Level 0
M = {'' e t};

树的搜索


        反复选择树上的不同分支对应着遍历这个树的不同顺序。在众多可能的排序中,有两种有着标准的名字:深度优先搜索方法(depth-first search)广度优先搜索(breadth-first search)

         深度优先的方法使用的是成为栈(stack)的数据结构。栈S为单元数组,只要栈是非空的,while循环就一直进行下去。

   S = {morse_tree};while ~isempty(S)N = S{1};S = S(2:end);if ~isempty(N)fprintf(' %s',N{1})S = {N{2} N{3} S{:}};endendfprintf('\n')

        广度优先搜索算法用了称为队列(queue)的数据结构。

%% Breadth first, with a queue.Q = {morse_tree};while ~isempty(Q)N = Q{1};Q = Q(2:end);if ~isempty(N)fprintf(' %s',N{1})Q = {Q{:} N{2} N{3}};endendfprintf('\n')

        队列采用了先进先出(FIFO)的策略,而堆栈采用了后进先出(LIFO)的策略。

function morse_gui(arg)
% MORSE_GUI  Interactive demonstration of Morse code and binary trees.if nargin == 0init_guielseif isequal(arg,'_depth')depthelseif isequal(arg,'_breadth') breadthelsetranslateend% ------------------------------------function depth% Depth first traversal of Morse code binary tree% Stack, LIFO, last in first out.% Insert new items at the top of the stack.S = {morse_tree};X = 0;Y = 0;while ~isempty(S)N = S{1};S = S(2:end);x = X(1);X = X(2:end);y = Y(1);Y = Y(2:end);if ~isempty(N)node(N{1},x,y)S = {N{2} N{3} S{:}};X = [2*x-(x>=0); 2*x+(x<=0); X];Y = [y+1; y+1; Y];endendend % depth% ------------------------------------function breadth% Breadth first traversal of Morse code binary tree.% Queue, FIFO, first in first out.% Insert new items at the end of the queue.Q = {morse_tree};X = 0;Y = 0;while ~isempty(Q)N = Q{1};Q = Q(2:end);x = X(1);X = X(2:end);y = Y(1);Y = Y(2:end);if ~isempty(N)node(N{1},x,y);Q = {Q{:} N{2} N{3}};X = [X; 2*x-(x>=0); 2*x+(x<=0)];Y = [Y; y+1; y+1];endendend % breadth% ------------------------------------function translate% Translate to and from Morse code.e = findobj('style','edit');s = findobj('string','sound');t = get(e,'string');if all(t=='.' | t=='-' | t==' ' | t=='*')t = decode(t);set(e,'string',t);elsecode = encode(t);set(e,'string',code);if get(s,'value') == 1morse_sound(code)endendif length(t)>=3 && isequal(t(1:3),'SOS')screamendend% ------------------------------------function code = encode(text)% ENCODE  Translate text to dots and dashes.% encode('text')code = '';text = upper(text);for k = 1:length(text);ch = text(k);% A blank in the text is worth three in the code.if ch == ' 'code = [code '   '];elsecode = [code encode_ch(ch) ' '];endendend % encode% ------------------------------------function dd = encode_ch(ch)% ENCODE_CH  Translate one character to dots and dashes.S = {morse_tree};D = {''};while ~isempty(S)N = S{1};dd = D{1};S = S(2:end);D = D(2:end);if ~isempty(N)if N{1} == ch;returnelseS = {N{2} N{3} S{:}};D = {[dd '.'] [dd '-'] D{:}};endendenddd = '*';end % encode_ch% ------------------------------------function text = decode(code)% DECODE  Translate strings of dots and dashes to text.% decode('string of dots, dashes and spaces')text = [];code = [code ' '];while ~isempty(code);k = find(code == ' ',1);ch = decode_dd(code(1:k));text = [text ch];code(1:k) = [];% Many blanks in the code is worth one in the text.if ~isempty(code) && code(1) == ' 'text = [text ' '];while ~isempty(code) && code(1) == ' 'code(1) = [];endendendend % decode% ------------------------------------function ch = decode_dd(dd)% DECODE_DD  Translate one character's worth of dots% and dashes to a single character of text.M = morse_tree;for k = 1:length(dd)if dd(k) == '.'M = M{2};elseif dd(k) == '-'M = M{3};endif isempty(M)ch = '*';returnendendch = M{1};end % decode_dd% ------------------------------------function init_gui% Initialize Morse code gui.global extendextend = 0;clf resetaxes('pos',[0 0 1 1])axis(16*[-1 1 0 2])axis square offset(gcf,'color','white')set(gca,'ydir','rev')uicontrol('style','push','string','depth', ...'units','normal','pos',[0.16 0.20 0.12 0.06], ...'callback','cla, morse_gui(''_depth'')')uicontrol('style','push','string','breadth', ...'units','normal','pos',[0.35 0.20 0.12 0.06], ...'callback','cla, morse_gui(''_breadth'')')uicontrol('style','toggle','string','sound','value',1, ...'units','normal','pos',[0.54 0.20 0.12 0.06]);uicontrol('style','toggle','string','extend','value',0, ...'units','normal','pos',[0.72 0.20 0.12 0.06], ...'callback', ['global extend, extend=get(gcbo,''value'');' ...'if extend==0, cla, end, axis(2^(4+extend)*[-1 1 0 2])']);uicontrol('style','edit','string', ...'Enter text or code to translate', ...'units','normal','pos',[0.16 0.04 0.68 0.08], ...'callback','cla, morse_gui(''_translate'')')end% ------------------------------------function node(ch,x,y)% Plot, and possibly play, node of Morse code binary tree.global extendr = 0.90;z = r*exp(2*pi*i*(0:32)/32);delta = 1/3;dkgreen = [0 1/2 0];lw = get(0,'defaultlinelinewidth')+0.5;fs = get(0,'defaulttextfontsize');if ~extendlw = lw+1;fs = fs+2;endp = 2^(4+extend-y);u = (x~=0)*(2*x+2*(x<=0)-1)*p;v = 4*(y+1);% Circleline(u+real(z),v+imag(z),'color','black','linewidth',lw)% Charactertext(u-delta,v,ch,'fontweight','bold','color',dkgreen,'fontsize',fs);% Connect node to parentif (x~=0)if y==1w = 0;elseif rem(x,2)==(x>0)w = u+p;elsew = u-p;endline([u w],[v-r v+r-4],'color','black','linewidth',lw)endif get(findobj('string','sound'),'value') == 1morse_sound(encode_ch(ch))pause(0.2)endpause(0.1)end% ------------------------------------function morse_sound(code,delta,note)% MORSE_SOUND  Play sound for dots and dashes.% morse_sound(code) plays code, a string of dots, dashes and spaces.% morse_sound(code,delta,note) time slice is delta and tone is note.% Default delta = 1/16 second.% Default note = 6, which is F above middle C.  See play_note.if nargin < 2delta = 1/16;endif nargin < 3note = 6;ends = findobj('string','sound');for k = 1:length(code)if get(s,'value') == 1switch code(k)case '.'play_note(note,delta)case '-'play_note(note,3*delta)case ' 'pause(3*delta)otherwise% Skip the characterendpause(delta)endendend  % morse_sound% ------------------------------------function play_note(note,T)% PLAY_NOTE  Play a musical note.% play_note(note,T)  Play a note for T seconds.% note is an integer specifying semitones above and below middle C.% There are 12 notes per octave.% play_note(0,1/2) plays middle C (~261.625 Hz) for 1/2 second.C4 = 440/2^(3/4);             % Middle C, hertzFs = 44100;                   % Sample rate, hertzt = (0:1/Fs:T);               % Linear time rampf = C4 * 2^(note/12);         % Frequency, hertzy = sin(2*pi*f*t);            % Sinusoidal signalk = 1:1000;                   % Attack and releaser = (k/1000);y(k) = r.*y(k);y(end+1-k) = r.*y(end+1-k);sound(y,Fs)                   % Playend  % play_noteend % morse_gui

解码和编码


        解码是将 “点和划” 描述的东西变成文字;编码过程正好反过来。

   function text = decode(code)% DECODE  Translate strings of dots and dashes to text.% decode('string of dots, dashes and spaces')text = [];code = [code ' '];while ~isempty(code);k = find(code == ' ',1);ch = decode_dd(code(1:k));text = [text ch];code(1:k) = [];% Many blanks in the code is worth one in the text.if ~isempty(code) && code(1) == ' 'text = [text ' '];while ~isempty(code) && code(1) == ' 'code(1) = [];endendendend % decode
 function dd = encode_ch(ch)% ENCODE_CH  Translate one character to dots and dashes.S = {morse_tree};D = {''};while ~isempty(S)N = S{1};dd = D{1};S = S(2:end);D = D(2:end);if ~isempty(N)if N{1} == ch;returnelseS = {N{2} N{3} S{:}};D = {[dd '.'] [dd '-'] D{:}};endendenddd = '*';end % encode_ch

摩尔斯电码表


        morse_code使用了递归算法函数traverse,这种递归调用的结果把C表格和含有“点”和“划”的dd字符串合并。在matlab中,可以使用char函数将数字转换成字母,如char(65)命令转换为A。

function C = morse_code(C,M,dd) 
% MORSE_CODE
% C = morse_code
% C = morse_code(morse_tree)
% C = morse_code(morse_tree_extended)
% Generate tables of the ASCII and Morse codes
% for the characters defined by the binary trees.if nargin < 3           % Choose binary treeif nargin == 0M = morse_tree;elseM = C;endC = cell(256,1);     % The temporary code tabledd = '';             % dots and dashesendif ~isempty(M)                        % Depth first searchif ~isempty(M{1})C{double(M{1})} = dd;           % Use ASCII value as an indexendC = morse_code(C,M{2},[dd '.']);   % Recursive callC = morse_code(C,M{3},[dd '-']);   % Recursive callendif nargin < 3                    % Final processing, convert to char.c = char(C{:});k = find(c(:,1) ~= ' ');      % Find the nonblank entries.b = blanks(length(k))';C = [char(k) b b int2str(k) b b char(C{k})];end

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/20383.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【Linux】Linux命令行大全——读书笔记1

《Linux命令行大全》 在线文档地址&#xff1a;The Linux Command Line 阅读笔记之第1&#xff5e;4章&#xff1a;引言&#xff1b;什么是shell&#xff1b;文件系统中跳转&#xff1b;研究操作系统 一、概念 GUI: 图形用户界面 GNU: GNU’s Not Unix! 的递归缩写 shell …

算法刷题Day 57 回文子串+最长回文子序列

Day 57 动态规划 647. 回文子串 暴力解法 class Solution {bool isPalindromic(const string &s) {int i 0, j s.size() - 1;while (i < j) {if (s[i] ! s[j]) {return false;}i; j--;}return true;}public:int countSubstrings(string s) {int sum 0;for (int i …

线段树详解 原理解释 + 构建步骤 + 代码(带模板)

目录 介绍&#xff1a; 定义&#xff1a; 以具体一个题目为例&#xff1a;​ 树的表示方法&#xff1a; 实现步骤&#xff1a; 构建结点属性&#xff1a; pushup函数&#xff1a; build函数&#xff1a; pushdown函数&#xff1a; modify函数&#xff1a; query…

『赠书活动 | 第十六期』《深入浅出Java虚拟机:JVM原理与实战》

&#x1f497;wei_shuo的个人主页 &#x1f4ab;wei_shuo的学习社区 &#x1f310;Hello World &#xff01; 『赠书活动 &#xff5c; 第十六期』 本期书籍&#xff1a;《深入浅出Java虚拟机&#xff1a;JVM原理与实战》 赠书规则&#xff1a;评论区&#xff1a;点赞&#xff…

STM32 CAN通信-CubeMX环境下CAN通信程序的编程与调试经验

文章目录 STM32 CAN通信-CubeMX环境下CAN通信程序的编程 STM32 CAN通信-CubeMX环境下CAN通信程序的编程 STM32F103ZE芯片 CAN通信测试代码&#xff1a; #include "main.h" #include "can.h"CAN_HandleTypeDef hcan1;void SystemClock_Config(void);int ma…

什么是函数式编程,应用场景是什么

什么是函数式编程&#xff0c;应用场景是什么 函数式编程和面向对象编程一样&#xff0c;是一种编程规范。强调执行的过程而非结果&#xff0c;通过一系列的嵌套的函数调用&#xff0c;完成一个运算过程。它主要有以下几个特点&#xff1a; 1.函数是"一等公民"&…

站点可靠性工程 (SRE)

随着世界各地的组织努力开发安全、可靠、可扩展且可持续的 IT 基础架构&#xff0c;对高效基础架构监控和管理的需求日益增长&#xff0c;企业正在用不可扩展的遗留架构换取现代解决方案&#xff0c;在尖端技术的推动下&#xff0c;这些使基础设施管理过程更加顺畅和轻松&#…

JS监听浏览器关闭、刷新及切换标签页触发事件

蛮简单的东西&#xff0c;知道就会&#xff0c;不知道就不会&#xff0c;没什么逻辑可言。简单记录一下&#xff0c;只为加深点儿印象。 visibilitychange visibilitychange可以监听到浏览器的切换标签页。 直接上代码&#xff1a; <script>document.addEventListe…

SpringBoot + minio实现分片上传、秒传、续传

什么是minio MinIO是一个基于Go实现的高性能、兼容S3协议的对象存储。它采用GNU AGPL v3开源协议&#xff0c;项目地址是https://github.com/minio/minio。 引用官网&#xff1a; MinIO是根据GNU Affero通用公共许可证v3.0发布的高性能对象存储。它与Amazon S3云存储服务兼容…

C++设计模式之访问者模式

C访问者设计模式 文章目录 C访问者设计模式什么是设计模式什么是访问者设计模式该模式有什么优缺点优点缺点 如何使用 什么是设计模式 设计模式是一种通用的解决方案&#xff0c;用于解决特定的一类问题。它是一种经过验证的代码组织方式&#xff0c;可以帮助开发人员更快地实…

Linux——平台设备及其驱动

目录 前言 一、平台设备 二、平台驱动 三、平台驱动简单实例 四、 电源管理 五、udev 和驱动的自动加载 六、使用平台设备的LED 驱动 七、自动创建设备节点 前言 要满足 Linux 设备模型&#xff0c;就必须有总线、设备和驱动。但是有的设备并没有对应的物理总线&#x…

互联网被裁的程序员,未来有什么方向呢?

做了一份程序员“失业”后的自救方向汇总&#xff1a; 接下来挨个聊聊。 产品经理 都说产品和技术总是相爱相杀&#xff0c;不过产品和技术的关系也是最近的。 无论是产品转技术&#xff0c;还是技术转产品&#xff0c;相对来说都是比较容易的&#xff0c;很多底层逻辑是互通…

后端通过CorsRegistry对象配置了全局跨域,但是前端仍然报CORS跨域错误

后端通过CorsRegistry配置了全局跨域&#xff0c;但是前端仍然报CORS跨域错误 问题背景 在实现登录功能时&#xff0c;我先是通过CorsRegistry配置了全局跨域&#xff0c;然后配置了一个登录拦截器后前端就报错CORS跨域错误 问题原因 前置知识 首先我们来了解一下什么是跨域错误…

无脑入门pytorch系列(一)—— nn.embedding

本系列教程适用于没有任何pytorch的同学&#xff08;简单的python语法还是要的&#xff09;&#xff0c;从代码的表层出发挖掘代码的深层含义&#xff0c;理解具体的意思和内涵。pytorch的很多函数看着非常简单&#xff0c;但是其中包含了很多内容&#xff0c;不了解其中的意思…

手游联运系统有什么优势?

手游联运系统有许多优势&#xff0c;其中一些重要的优势包括&#xff1a; 1、游戏联运 手游联运系统可以将多款手游整合在一起&#xff0c;形成游戏联运平台&#xff0c;提供给玩家更多游戏选择&#xff0c;增加游戏的多样性和趣味性。 2、推广渠道管理 手游联运系统可以集…

Vuex:Vue.js应用程序的状态管理模式

介绍 在Vue.js应用程序中&#xff0c;随着项目复杂度的增加&#xff0c;组件之间的数据共享和管理变得困难。为了解决这个问题&#xff0c;Vue.js提供了一个名为Vuex的状态管理模式。Vuex可以帮助我们更有效地组织、管理和共享应用程序的状态。 什么是Vuex&#xff1f; Vuex…

网络安全策略应包含哪些?

网络安全策略是保护组织免受网络威胁的关键措施。良好的网络安全策略可以确保数据和系统的保密性、完整性和可用性。以下是一个典型的网络安全策略应包含的几个重要方面&#xff1a; 1. 强化密码策略&#xff1a;采用强密码&#xff0c;要求定期更换密码&#xff0c;并使用多因…

Java类集框架(一)

目录 1.Collection集合接口 2.List 接口 (常用子类 ArrayList ,LinkedList,Vector) 3.Set 集合 接口(常用子类 HashSet LinkedHashSet,TreeSet) 4.集合输出(iterator , Enumeration) 1.Collection集合接口 Collection是集合中最大父接口&#xff0c;在接口中定义了核心的…

Java设计模式-解释器模式

解释器模式 1.解释器模式 解释器模式&#xff0c;给定一个语言&#xff0c;定义它的文法的一种表示&#xff0c;并定义一个解释器&#xff0c;这个解释器使用该表示来解释语言中的句子。 其实解释器模式很简单的&#xff0c;就是一个翻译的过程&#xff0c;就像翻译软件&…

vue中各种混淆用法汇总

✨在生成、导出、导入、使用 Vue 组件的时候&#xff0c;像我这种新手就会常常被位于不同文件的 new Vue() 、 export default{} 搞得晕头转向。本文对常见用法汇总区分 new Vue() &#x1f4a6;Vue()就是一个构造函数&#xff0c;new Vue()是创建一个 vue 实例。该实例是一个…