Matlab Octave - yszheda/wiki GitHub Wiki
Y = fix(X) 将 X 的每个元素朝零方向四舍五入为最近的整数。对于正方向的 X,fix 的行为与 floor 相同。对于负方向的 X,fix 的行为与 ceil 相同。
B = A.*(A>0);
C = A.*(A>0)*100 + A.*(A<0);
cd(fileparts(mfilename('fullpath')))
for iN = 1:nN
legendCell{iN} = num2str(N(iN),'N=%-d');
end
legend(legendCell)
figure(1)
% plot
figure(2)
% plot
% plot
hold on
% plot
h1 = 0.05 * randn(1, 10000);
h2 = 0.10 * randn(1, 10000);
h3 = 0.30 * randn(1, 10000);
[counts1, binCenters1] = hist(h1, 500);
[counts2, binCenters2] = hist(h2, 500);
[counts3, binCenters3] = hist(h3, 500);
plot(binCenters1, counts1, 'r-');
hold on;
plot(binCenters2, counts2, 'g-');
plot(binCenters3, counts3, 'b-');
grid on;
% Put up legend.
legend1 = sprintf('mu = %.3f', mean(h1));
legend2 = sprintf('mu = %.3f', mean(h2));
legend3 = sprintf('mu = %.3f', mean(h3));
legend({legend1, legend2, legend3});
figure;
axes;
axis([0 100 0 1000])
set(gca,'XTick',0:20:100);
set(gca,'YTick',0:200:1000);
- Matlab坐标轴间隔怎么设定
- Specify Axis Tick Values and Labels
- How do I control axis tick labels, limits, and axes tick locations?
- Matlab设置网格线密度(坐标精度)
- matlab 设置坐标轴的有效数字
- Matlab坐标修改 gca
- https://cn.mathworks.com/help/matlab/ref/errorbar.html
- How can I add standard error bars to individual points on a scatter plot with known standard deviation?
- How can I add error bars on a scatter plot using the calculated errors?
- How to plot an error bar plot with standard deviation values in MATLAB?
x = 0:pi/3:pi;
y = sin(x);
h=errorbar(x,y,e,'rx:')
hchildren = get(h,'children');
set(hchildren(1), 'LineWidth', 1, 'Color', 'b')
set(hchildren(2), 'LineWidth', 3, 'Color', 'g');
- Adjust error bar width in Matlab
- How do I change the width of the horizontal lines at top and bottom of error bars in my Errorbar plot?
hf = figure;
X = 0:pi/10:pi;
Y = sin(X);
E = std(Y)*ones(size(X));
ha = errorbar(X,Y,E);
hb = get(ha,'children');
Xdata = get(hb(2),'Xdata');
temp = 4:3:length(Xdata);
temp(3:3:end) = [];
% xleft and xright contain the indices of the left and right
% endpoints of the horizontal lines
xleft = temp; xright = temp+1;
% Increase line length by 0.2 units
Xdata(xleft) = Xdata(xleft) - .1;
Xdata(xright) = Xdata(xright) + .1;
set(hb(2),'Xdata',Xdata)
load <file>
print -deps foo.eps
% colorful eps
print -depsc test.eps
print -color -depsc test.eps
save('newfile.txt', 'var1, 'var2', ..., '-ascii')
- https://stackoverflow.com/questions/22010495/how-to-print-a-string-in-matlab
- https://cn.mathworks.com/help/matlab/ref/disp.html
- matlab中 fprintf 和disp的用法
- https://stackoverflow.com/questions/5895118/matlab-display-messages
- Displaying text in the command window when running a program
- How do I print (output) in Matlab?
prompt = 'Do you want more? Y/N [Y]: ';
str = input(prompt,'s');
if isempty(str)
str = 'Y';
end
- https://cn.mathworks.com/help/matlab/ref/input.html
- how do i code this - ask for input but default to preset value if required.
E.g. escape "'":
xlabel_name = input('Please enter xlabel (default is ''samples''):', 's');
function f(arg1,arg2,arg3)
if nargin < 3
arg3 = 'some default'
end
end