matlab代码怎么写

1. MATLAB编程题,请问代码怎么写 Take a photo of yourself
//no operations
Read your photo with Matlab
//I=imread('aa.jpg');
Transform the photo from color image to gray image
//I_gray=rgb2gray(I);
Re-size the image (H*W=300*600)
//H=300;W=600;
//I_reshape=reshape(I_gray,H,W);
Transform the data format from 'uint8' to 'double'
//I_double=double(I_reshape);
Adjust the contrast of the image based on the equation
OUT = Average + (IN – Average) * ( 1 + percent)
//
Average=xxxx;
percent=xxxx;
for i=1:H
for j=1:W
I_out(i,j)= Average + (I_double(i,j) – Average) * ( 1 + percent);
end
end
Save the result image with 'jpg' format
//imwrite(uint8(I_out),'a_out.jpg');
2. Matlab 代码编写 function temp = converTo(CorF,t)% ℃ = (°F - 32)/1.8% °F = ℃ * 1.8 + 32if nargin <2 fprintf('Usage: converTo(''Celsius'',100) or converTo(''Fahrenheit'',37)\n'); else if strcmp(CorF,'Celsius') temp = (t-32)/1.8; elseif strcmp(CorF,'Fahrenheit') temp = t*1.8+32; else fprintf('Error: Celsius or Fahrenheit\n'); endend测试: >> converToUsage: converTo('Celsius',100) or converTo('Fahrenheit',37) >> converTo(100)Usage: converTo('Celsius',100) or converTo('Fahrenheit',37) >> converTo('Celsius',100) ans = 37.7778 >> converTo('Fahrenheit',37) ans = 98.6000 >> converTo('Fah',37)Error: Celsius or Fahrenheit 。
3. matlab源代码 hrollfcoef这个函数不是matlab自带的
function [xh] = hrollfcoef(irfn,ipoint,sr,alfs,ncc)
%****************** variables *************************
% irfn : Number of symbols to use filtering
% ipoint : Number of samples in one symbol
% sr : symbol rate
% alfs : rolloff coeficiense
% ncc : 1 -- transmitting filter 0 -- receiving filter
% *****************************************************
xi=zeros(1,irfn*ipoint+1);
xq=zeros(1,irfn*ipoint+1);
point = ipoint;
tr = sr ;
tstp = 1.0 ./ tr ./ ipoint;
n = ipoint .* irfn;
mid = ( n ./ 2 ) + 1;
sub1 = 4.0 .* alfs .* tr; % 4*alpha*R_s
for i = 1 : n
icon = i - mid;
ym = icon;
if icon == 0.0
xt = (1.0-alfs+4.0.*alfs./pi).* tr; % h(0)
else
sub2 =16.0.*alfs.*alfs.*ym.*ym./ipoint./ipoint;
if sub2 ~= 1.0
x1=sin(pi*(1.0-alfs)/ipoint*ym)./pi./(1.0-sub2)./ym./tstp;
x2=cos(pi*(1.0+alfs)/ipoint*ym)./pi.*sub1./(1.0-sub2);
xt = x1 + x2; % h(t) plot((1:length(xh)),xh)
【matlab代码怎么写】else % (4alphaRst)^2 = 1plot((1:length(xh)),xh)
xt = alfs.*tr.*((1.0-2.0/pi).*cos(pi/4.0/alfs)+(1.0+2.0./pi).*sin(pi/4.0/alfs))./sqrt(2.0);
end % if sub2 ~= 1.0
end % if icon == 0.0
if ncc == 0 % in the case of receiver
xh( i ) = xt ./ ipoint ./ tr; % normalization
elseif ncc == 1 % in the case of transmitter
xh( i ) = xt ./ tr; % normalization
else
error('ncc error');
end % if ncc == 0
end % for i = 1 : n
%******************** end of file ***************************
网上找的 , 你看看能不能拼到你那个程序里去

matlab代码怎么写

文章插图